Java基础入门值文件操作

常见文件操作

1
2
3
4
5
6
7
8
9
10
String filePath = "E:\\home\\feiTest";
File file = new File(filePath);
file.isFile(); // 判断当前文件对象是否为文件
file.isDirectory(); // 判断当前文件夹对象是否为文件
file.exists(); // 判断文件对象是否存在
file.mkdirs(); // 创建多级文件目录
file.createNewFile(); // 创建新文件
file.getName(); // 获取文件名字
file.length(); // 文件大小
file.lastModified(); // 文件最后修改时间