java.io.Inputs and java.io.Ouputs
Rémi Forax
forax at univ-mlv.fr
Sun Nov 16 06:21:52 PST 2008
Hi alan, hi all,
Wow, I think its a very good idea to introduce static methods
for reading/writing lines.
Here is my review of those methods
(based on putback http://hg.openjdk.java.net/nio/nio/jdk/rev/d6c73618eaf6)
- Providing a closeUnchecked is a good idea but i don't see
why readAllBytes*() need use it.
- characters based method readAllLines/writeLines() should have
a variation that takes a Charset as parameter.
It will avoid to use Charset.defaultCharset().name() in some
writeLines().
Btw, readAllLines and writeLines is not a coherent naming scheme,
in my opinion, writeLines should be rewritten writeAllLines.
- readAllLines should be lazy, i.e. returns an Iterable<String>,
its iterator should close the stream when hasNext() return false.
I think Python already do something like that.
- writeLines should take an Iterable<? extends CharSequence> instead
of a List<String>, implwriteLines() should be re-written :
for (CharSequence line: lines) {
writer.write(line.toString());
writer.newLine();
}
A more general question, how about word based read methods ?
I am a commiter on another OpenJDK workspace,
so if you want I think I am able to create a patch,
ask for reviews and if it's ok, push the patch.
regards,
Rémi
More information about the nio-dev
mailing list