try-with-resources on arbitrary multiple files? (original) (raw)
Wang Weijun weijun.wang at oracle.com
Tue Apr 22 01🔞45 UTC 2014
- Previous message: StringBuilder instead of StringBuffer in java.util package
- Next message: try-with-resources on arbitrary multiple files?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
If I copy a file to another I can
try (src = open(ifile); dest = open(ofile)) { while (!src.EOF) dest.write(src.read()); }
but what if there are multiple destinations? Is there something like
try (src = open(ifile); manager = new CloseableManager()) { for (ofile: ofiles) { manager.register(open(ofile)); } while (!src.EOF) { buffer = src.read(); for (dest: manager) dest.write(buffer); } }
Thanks Max
- Previous message: StringBuilder instead of StringBuffer in java.util package
- Next message: try-with-resources on arbitrary multiple files?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]