반응형
* description : File 클래스 : 파일생성 또는 폴더 생성, 정보 보기 기능
public class FileApplication {
public static void main(String[] args) throws Exception {
// TODO : 1) 텍스트 파일을 읽어서 리스트 배열로 가져오기 : Files.readAllLines(Paths.get(경로))
List<String> lines
= Files.readAllLines(Paths.get("src/main/resources/file1.txt"));
System.out.println(lines); // 배열 출력
// TODO : 2) byte 파일을 읽어서 데이터 가져오기
byte[] bytes = Files.readAllBytes(Paths.get("src/main/resources/test1.db"));
System.out.println(Arrays.toString(bytes)); // 결과 출력
}
}
실행결과
[hello, how are you, nice to meet you]
[10, 20, 30]
반응형
'Java > Java 이론' 카테고리의 다른 글
중첩 클래스 (0) | 2023.10.02 |
---|---|
람다 함수 (0) | 2023.10.02 |
objectstream (0) | 2023.10.02 |
printstream (0) | 2023.10.02 |
보조스트림 : 기본 자료형으로 입출력하기 (0) | 2023.10.02 |