package CHAPTER13;

import java.io.File; // 파일 관리를 위한 File 클래스 가져오기
import java.io.IOException; // 입출력 예외 처리를 위한 IOException 가져오기

public class C13_12_FileExample { // 파일 관리 예제 클래스
    public static void main(String[] args) {
        File file = new File("text.txt"); // "text.txt" 파일 객체 생성

        try {
            // 파일이 존재하지 않으면 새 파일 생성
            if (file.createNewFile()) {
                System.out.println("파일이 생성되었습니다: " + file.getAbsolutePath()); // 파일 경로 출력
            } else {
                System.out.println("파일이 이미 존재합니다."); // 기존 파일 존재 여부 출력
            }
        } catch (IOException e) { // 파일 생성 중 예외 발생 시 처리
            e.printStackTrace();
        }

        // 파일 정보 출력
        System.out.println("파일 존재 여부: " + file.exists()); // 파일 존재 여부 확인
        System.out.println("파일 크기: " + file.length() + " 바이트"); // 파일 크기 출력
        System.out.println("파일이 디렉터리인지 여부: " + file.isDirectory()); // 파일이 디렉터리인지 확인
    }
}

