Nice addition in jdk7!
-------- Original Message --------
Subject: java.io.Inputs and java.io.Ouputs
Date: Sun, 16 Nov 2008 15:21:52 +0100
From: Rémi Forax <forax_at_univ-mlv.fr>
To: Alan.Bateman_at_Sun.COM
CC: nio-dev_at_openjdk.java.net
References: <20081116091706.6EDE4D550_at_hg.openjdk.java.net>
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