-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFiles.java
More file actions
29 lines (29 loc) · 784 Bytes
/
Files.java
File metadata and controls
29 lines (29 loc) · 784 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
import java.io.*;
class Files
{
public static void main(String args[])throws NullPointerException
{
String dirName = "E://test111";
File f = new File(dirName, "work.txt");
File f3 = new File(dirName,"renFile.txt");
System.out.println("File name is:" +f.getName());
System.out.println("Path of the file is:" +f.getPath());
System.out.println("Parent directory is:" +f.getParent());
System.out.println("Listing the contents of directory");
File f1 = new File("E://test111");
String s[] = f1.list();
for(int i = 0;i<s.length;i++)
{
File f2 = new File("\t" +dirName+ "/" +s[i]);
if(f2.isDirectory())
{
f2.delete();
System.out.println("\t" +s[i] + "is a directory");
}
else
{
System.out.println("\t" +s[i] + "is a file");
}
}
}
}