使用Java的java.nio.file.readAllLines时是否需要使用try-with-r
java源码中说了: Read all lines from a file. This method ensures that the file is * closed when all bytes have been read or an I/O error, or other runtime * exception, is thrown. Bytes from the file are decoded into characters * using the specified charset.
其中,实现中使用了新的try{} 语句打开文件,所以会自动关闭文件;
赞0
踩0