Java OutputStream for multiple files
1 answer
You can use Apache Commons IO TeeOutputStream for this purpose. This OutputStream proxies all bytes written to it into two base OutputStreams. You can use multiple TeeOutputStreams
in a chain if you want to write more than two OutputStreams at once.
OutputStream out = new TeeOutputStream(new FileOutputStream(new File("A")), new TeeOutputStream(new FileOutputStream(new File("B")), new FileOutputStream(new File("C")))))
+3
source to share