I'm tryting to learn the nio 2
package in Java 7 and i stumbled upon the Files.readAllLines(Path p, Charset cs)
method. I find it very useful, but i'm of the opinion that there should be a version without the cs
parameter, just like :
public static List<String> readAllLines(String path)
throws IOException
{ return readAllLines(Paths.get(path), Charset.defaultCharset());}
I convinced that most of the time the method will be called with the default Charset anyway, so why no the shorcut. Is there anything i'm missing about charsets that would justify not having this method? I'm quite surprised because Scala has this option:
Source.fromFile("fileName").getLines
so i don't see why Java shouldn't. Any views?
readAllLines(String path)
was added in Java SE 8, and the assumed charset is always UTF-8. – Mneme