Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.
Close

cancelable Streams

If you want to cancel a Stream you have often to implement custom code which throws IOException like it would happen if the used Stream would be really canceled.
For that purpose you can decorate used InputStream or OutputStream with Cancelable decorators and cancel used Streams by calling a cancel() method of the decorator. In such case an IOException would be thrown to the client and the client (stream-user).
The code above demonstrates how an InputStream can be canceled:

InputStream is = createInputStream(50);
final CancelableInputStream_1x2 cis = CancelableInputStream_1x2.of(is);

cis.cancel();

In the same manner you can decorate an OutputStream to be cancelable:

OutputStream os = createOutputStream();
final CancelableOutputStream_1x2 cos = CancelableOutputStream_1x2.of(os);

cos.cancel();

Please look at Examples section to see more examples.