X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fstreams%2FReplaceOutputStream.java;h=e7e6c9f5a7c03456902e471864722af00478de48;hp=ff871eb815d4b5a8672cfd746449a09524684968;hb=7194ac50b29064a013f177fc9cfc5aaa131a8ec4;hpb=a6a73de36765b85947ac885529da82d3e7189269 diff --git a/src/be/nikiroo/utils/streams/ReplaceOutputStream.java b/src/be/nikiroo/utils/streams/ReplaceOutputStream.java index ff871eb..e7e6c9f 100644 --- a/src/be/nikiroo/utils/streams/ReplaceOutputStream.java +++ b/src/be/nikiroo/utils/streams/ReplaceOutputStream.java @@ -88,9 +88,30 @@ public class ReplaceOutputStream extends BufferedOutputStream { this.tos = tos; } + /** + * Flush the {@link BufferedOutputStream}, write the current buffered data + * to (and optionally also flush) the under-laying stream. + *

+ * 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). + *

+ * But be careful! If a replacement could be done with the end o the + * currently buffered data and the start of the data to come, we obviously + * will not be able to do it. + * + * @param includingSubStream + * also flush the under-laying stream + * @throws IOException + * in case of I/O error + */ @Override public void flush(boolean includingSubStream) throws IOException { - // Note: very simple, not efficient implementation, sorry. + // Note: very simple, not efficient implementation; sorry. while (start < stop) { boolean replaced = false; for (int i = 0; i < froms.length; i++) {