I am trying to read a simple text file into a String. Of course there is the usual way of getting the input stream and iterating with readLine() and reading contents into String.
Having done this hundreds of times in past, I just wondered how can I do this in minimun lines of code? Isn't there something in java like String fileContents = XXX.readFile(myFile/*File*/)
.. rather anything that looks as simple as this?
I know there are libraries like apache file IO which provide such simplifications or even I can write a simple Util class to do this. But all that I wonder is - this is a so frequent operation that everyone needs then why doesn't java provide such simple function? Isnt there really a single method somewhere to read a file into string with some default or specified encoding?