files

    Java - File read 2가지 방법

    Java를 사용하여 파일을 읽어야 하는 경우 여러가지 방법이 있지만, 그 중 2가지 방법을 소개하고자 한다. Files.readAllLines(Path) Files.newBufferedReader(Path) & readLine() Files.readAllLines(Path) Path path = Path.of("/users/user/document/text.txt"); try { List content = Files.readAllLines(path); for(String line : content) { System.out.println(line); } } catch (IOException e) { System.out.println("File open failed : " + e.getMessage()); ..