X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fstreams%2FBufferedOutputStream.java;h=14425345c179196d8944d3c391b60393c28db9d5;hb=28bee1c360ac061db48395356f36ef62c2923bf1;hp=5f7e6ebc7011d4df33c10e95356ad1a91f08b925;hpb=617ad86c825bf7fdc85b72c3a453d9c90bd8f770;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/streams/BufferedOutputStream.java b/src/be/nikiroo/utils/streams/BufferedOutputStream.java index 5f7e6eb..1442534 100644 --- a/src/be/nikiroo/utils/streams/BufferedOutputStream.java +++ b/src/be/nikiroo/utils/streams/BufferedOutputStream.java @@ -177,15 +177,22 @@ public class BufferedOutputStream extends OutputStream { *

* If {@link BufferedOutputStream#bypassFlush} is false, all writes to the * under-laying stream are done in this method. + *

+ * This can be used if you want to write some data in the under-laying + * stream yourself (in that case, flush this {@link BufferedOutputStream} + * with or without flushing the under-laying stream, then you can write to + * the under-laying stream). * * @param includingSubStream * also flush the under-laying stream * @throws IOException * in case of I/O error */ - protected void flush(boolean includingSubStream) throws IOException { - out.write(buffer, start, stop - start); - bytesWritten += (stop - start); + public void flush(boolean includingSubStream) throws IOException { + if (stop > start) { + out.write(buffer, start, stop - start); + bytesWritten += (stop - start); + } start = 0; stop = 0;