If the file does not exist, what will readalllines return?
The Oracle document says here, files The readalllines (path, charset CS) method returns the lines in the file as list < string >
Solution
It doesn't "return" anything As Javadoc said, the readalllines method will throw IOException in case of I / O error
Specifically, when the file does not exist, the implementation of JDK 8 I am using will throw Java nio. file. Nosuchfileexception, which is a subclass of IOException
This is really not your concern This is why there are interfaces and encapsulation, so you don't need to look inside The important thing is that it is an object that respects the list interface contract
If you have to know, you can call on the returned object Getclass() to check The implementation of JDK 8 I'm using just returns Java util. ArrayList. Another implementation may return other content. As I mentioned earlier, we shouldn't even try to see what it is to avoid any risk of breaking the encapsulation