File类
//exists()判断文件是否存在
//getName()返回文件名
//getAbsolutePath() 返回文件的绝对路径
//length()返回文件的大小
//getParentFile()找到父文件所在的位置
//mkdirs()创建目录文件
//delete()删除文件
import java.io.*;
public class T_File {
public static void main(String[] args) throws IOException{
//File f = new File("file");
//File f = new File("C:"+File.separator+"h"+File.separator+"newfile.txt");
//f.createNewFile();在C盘下一个叫h的目录文件下创建newfile.txt
File f1 = new File("new/new01","newfile01");
if(f1.exists()) {
System.out.println("文件名:"+f1.getName());
System.out.println("文件绝对路径:"+f1.getAbsolutePath());
System.out.println("文件大小:"+f1.length());
System.out.println("文件最后修改时间:"+new Date(f1.lastModified());
System.out.println("文件");
}else {
f1.getParentFile().mkdirs();
try {
f1.createNewFile();
}catch (Exception e) {
e.printStackTrace();
}finally {
//f1.delete();
}
}
}}
```