package com.io.day2;
import java.io.File;
import java.io.IOException;
public class FileTest {
public static void main(String[] args) {
File f = new File("text/test.txt");
System.out.println("경로 제외한 파일명 : "+f.getName());
// test.txt
System.out.println("경로 포함한 파일명 : "+f.getPath());
// text\test.txt
System.out.println("절대경로 파일명 : "+f.getAbsolutePath());
// C:\lecture\workspace.list\java_ws\advanced\text\test.txt
System.out.println("파일이 속해있는 디렉토리 : "+f.getParent());
// text
System.out.println("pathSeparator : "+File.pathSeparator);
// ;
System.out.println("Separator : "+File.separator);
// \
File f2 = new File("text","newFile.txt");
try {
f2.createNewFile();
if(f2.exists()) {
System.out.println("파일생성");
}
}catch(IOException e) {
e.printStackTrace();
}
}
}