Skip to main content
10 events
when toggle format what by license comment
Feb 24, 2013 at 17:47 comment added Kevin @ZettaSuro A single method call instead of a loop every time. Set up the stream once to write to all the streams you want, then just teeos.write(stuff).
Feb 24, 2013 at 17:47 comment added rurouniwallace I see...so then what is the advantage of using TeeOutputStream over simply iterating over each output stream yourself?
Feb 24, 2013 at 17:44 comment added Kevin source: @override public synchronized void write(final int b) throws IOException { super.write(b); this.branch.write(b); }
Feb 24, 2013 at 17:43 comment added Kevin Just checked, TOS is indeed in series, check the source here
Feb 24, 2013 at 17:33 comment added Kevin I'd bet quite a bit that if I look at the Apache TeeOutputStream source, it does them in series like this, not in parallel in separate threads.
Feb 24, 2013 at 17:32 comment added Kevin @ZettaSuro So spawn them in threads, but that would not be any faster if the files are on the same physical disk, and potentially slower, and I'm quite sure that's not what the OP meant. It does write all the streams in one method call, which is the problem at hand.
Feb 24, 2013 at 17:13 comment added rurouniwallace @Kevin No thanks. A for-each loop does not solve the problem of how to write them simultaneously. A for-each will write to the streams in sequence, they won't be written in parallel (i.e. simultaneously).
Feb 24, 2013 at 5:28 comment added rurouniwallace This doesn't really answer the question of how to write to all of them simultaneous.
Nov 2, 2011 at 21:17 comment added Steve McLeod Nothing in I/O is ever trivial. Even if it seems so at first.
Nov 2, 2011 at 21:15 history answered Kevin CC BY-SA 3.0