-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileTest.java
More file actions
39 lines (28 loc) · 907 Bytes
/
Copy pathFileTest.java
File metadata and controls
39 lines (28 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package java_base;
import java.io.File;
public class FileTest {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
File f = new File("src\\java_base\\FileTest.java");
System.out.println("f.exists() = " + f.exists());
System.out.println("f.isDirectory() = " + f.isDirectory() );
System.err.println("f.length() = " + f.length());
System.out.println("f.getName() = " + f.getName( ));
System.out.println("f.getParent() = " + f.getParent());
System.out.println("f.getPath() = " + f.getPath());
// File f1 = new File("d:\\hb\\hd\\hdc");
// f1.mkdirs();
//
// File f2 = new File("d:\\onefile");
// f2.mkdir();
File f4 = new File("d:c\\a.txt");
File f3 = new File("d:\\b.txt");
File f5 = new File("d:\\new.txt");
f5.createNewFile();
f3.renameTo(f4);
}
}
/*
* File 是文件指针
* 能进行创建文件,创建目录,重命名等操作
*/