In the comments to my answer about reading an entire file into memory using scala.io.Source
, I asserted that the reason there is no read-whole-file-into-String method in Java is that it is not (of course) scalable with regards to how big the file is and how much heap you have.
However, I guess everyone has some method like:
String contents = IOUtil.readFile(f, "utf-8");
And the implementation of the method is just a few lines of code. Why did they not just add this to the JDK in the first place? Is it my (scalability) reason, or is there some other reason it was omitted?