forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileMethods.java
More file actions
37 lines (29 loc) · 970 Bytes
/
FileMethods.java
File metadata and controls
37 lines (29 loc) · 970 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
package file;
import java.io.File;
import java.io.IOException;
public class FileMethods {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File f = new File("D:/DEEP");
f.mkdirs();
File [] f2 = f.listFiles();
for (int i = 0; i < f2.length; i++) {
System.out.println(f2[i]);
}
System.out.println("count : "+f2.length);
File f1 = new File(f,"first.txt");
f1.createNewFile();
System.out.println("3)getAbsolutePath : "+f1.getAbsolutePath());
System.out.println("4)getCanonicalPath : "+f1.getCanonicalPath());
System.out.println("5)getParent : "+f1.getParent());
System.out.println("6)isDirectory : "+f.isDirectory());
System.out.println("7)isFile : "+f1.isFile());
System.out.println("8)canRead : "+f1.canRead());
System.out.println("9)canWrite : "+f1.canWrite());
System.out.println("10)isHidden : "+f1.isHidden());
}
}