News for hackers. Stuff that matters.
Re:Java for beginners by AndrewDucker on Friday June 23, 2017 @09:27AM (#14618985)
I keep wanting to like Java, but they insist on everything being done the hard way compared to C#.

Sure, you want to provide a bunch of different readers, and let people put them together however you want.

But compare the example there of using a BufferedReader in a loop to read in a file, and compare to the equivalent in C# - File.ReadLines (which gives you an IEnumerable<string>) or even File.ReadAllLines (which gives you a string[]). 99% of the time that's all you want, and yet Java makes you do the work yourself rather than just giving you a utility method.

Re:Java for beginners by martinp on Friday June 23, 2017 @09:30AM (#14619008)
Bad example. You can do this in Java 8: java.nio.file.Files.readAllLines(path) which returns List<String>.
Re:Java for beginners by singularity2001 on Friday June 23, 2017 @10:32AM (#14619396)
so they fix this one horribly convoluted use case, but most of the others are remaining?
Re:Java for beginners by noobymatze on Friday June 23, 2017 @09:44AM (#14619076)
There is a utility method `Files.readAllLines` [1] (even since Java 7) which gives you a List<String>. Since Java 8 there is even a lazy variant `Files.lines()` [2], which returns a Stream<String>. Though you gotta be a bit careful with that last one and be sure to close the underlying reader, as mentioned in the docs.

I get your sentiment though.

[1]: https://docs.oracle.com/javase/7/docs/api/java/nio/file/File... [2]: https://docs.oracle.com/javase/8/docs/api/java/nio/file/File...