5 ms·
Ehh... When there are many questions on SO asking how to read a file in Java and the answers all require about a dozen LOC and have hundreds of upvotes [0,1,2]
by zbjornson 10y ago
Ehh... When there are many questions on SO asking how to read a file in Java and the answers all require about a dozen LOC and have hundreds of upvotes [0,1,2] I think I agree with the earlier comment that it's more a barrier to distribution and acquisition of modules. There are plenty of tiny npm modules that do less than a Java wrapper for easily reading files would.
[0] http://stackoverflow.com/questions/4716503/reading-a-plain-text-file-in-java http://stackoverflow.com/questions/4716503/reading-a-plain-t...
[1] http://stackoverflow.com/questions/326390/how-do-i-create-a-java-string-from-the-contents-of-a-file http://stackoverflow.com/questions/326390/how-do-i-create-a-...
[2] http://stackoverflow.com/questions/3402735/what-is-simplest-way-to-read-a-file-into-string http://stackoverflow.com/questions/3402735/what-is-simplest-...
- cm2187 10y agoI am not familiar enough with java which I assumed was a match for .net. But one line of code in .net. IO.File.ReadAllText(FilePath)
- zbjornson 10y agoYeah, .net is way nicer than java and your argument holds pretty well in that case.
- fauigerzigerk 10y agoWhat's wrong with new String(Files.readAllBytes(path)); or new String(Files.readAllBytes(path), StandardCharsets.UTF_8); ?