-
Notifications
You must be signed in to change notification settings - Fork 0
/
File info
48 lines (37 loc) · 970 Bytes
/
File info
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
40
41
42
43
44
45
46
47
48
import java.io.IOException;
import java.util.Scanner;
import java.io.File;
public class File_details {
public static void main(String [] args)throws IOException
{
Scanner src =new Scanner (System.in);
System.out.print("enter the file name : ");
String n=src.nextLine();
File f =new File(n);
if(f.createNewFile())
{
System.out.println("file name : "+f.getName());
System.out.println("file parent : "+f.getParent());
System.out.println("file path : "+f.getPath());
System.out.println("file space : "+f.getTotalSpace());
}
if(f.exists())
{
System.out.println("file readable : "+f.canRead());
System.out.println("file writable : "+f.canWrite());
System.out.println("file directory : "+f.isDirectory());
}
}
}
/**
* OUTPUT
* ------
* enter the file name : RAF
file name : RAF
file parent : null
file path : RAF
file space : 324551045120
file readable : true
file writable : true
file directory : false
*/