标签:some jpg tac cto data tde efi sys getpath
@Test
public void test1(){
File file1 = new File("/Users/truman/Desktop/Life");
System.out.println(file1);
System.out.println(file1.isDirectory());
File file2 = new File("/Users/truman", "Pictures");
System.out.println(file2);
System.out.println(file2.isDirectory());
File file3 = new File(file2, "aiaiai.jpg");
System.out.println(file3);
}
@Test
public void testFileMethod(){
File file1 = new File("/Users/truman/Desktop");
System.out.println(file1.getAbsolutePath()); // /Users/truman/Desktop
System.out.println(file1.getPath()); // /Users/truman/Desktop
System.out.println(file1.getName()); // Desktop
System.out.println(file1.getParent()); // /Users/truman
System.out.println(file1.length()); // 672
System.out.println(file1.lastModified()); // 1593138078000
System.out.println(new Date(file1.lastModified())); // Fri Jun 26 10:21:18 CST 2020
}
String[] list = file1.list();
System.out.println(Arrays.toString(list));
// [Villanelle, Database, 数学建模书籍, .DS_Store, Something, .localized, ...]
File[] files = file1.listFiles();
@Test
public void testCreateFile(){
File file1 = new File("hi.txt");
if(!file1.exists()){
try {
file1.createNewFile();
System.out.println("New File Created.");
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Test
public void testDelete(){
File file1 = new File("hi.txt");
if (file1.exists()){
file1.delete();
System.out.println("File Deleted.");
}
}
}
标签:some jpg tac cto data tde efi sys getpath
原文地址:https://www.cnblogs.com/nedrain/p/13287804.html