Information
Coddy의 Java 파일 처리 코스 레슨 — 11개 중 3번째.
이전 레슨에서 우리는 모든 파일로부터 File 객체를 생성하는 방법을 살펴보았습니다. 이제 몇 가지 기본적인 연산을 살펴보겠습니다:
File dataFile = new File("data.txt");
System.out.println("File name: " + dataFile.getName());
System.out.println("Absolute path: " + dataFile.getAbsolutePath());
System.out.println("File size in bytes " + dataFile.length());위의 코드는 data.txt 파일의 이름, 절대 경로 및 크기를 출력합니다.
챌린지
쉬움파일 시스템에 "coddy.txt"라는 이름의 파일을 생성했습니다.
여러분의 과제는 이 파일의 객체를 생성하고 파일의 이름, 경로, 크기를 줄바꿈으로 구분하여 출력하는 것입니다.
직접 해보기
import java.io.File;
class Main {
public static void main(String[] args) {
// 여기에 코드를 작성하세요
}
}