-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqb302.java
More file actions
30 lines (23 loc) · 738 Bytes
/
Copy pathqb302.java
File metadata and controls
30 lines (23 loc) · 738 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
import java.io.*;
class QB302 {
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Enter File name in CMD");
return;
}
String cmd = args[0];
File f = new File(cmd);
if (f.isFile()) {
System.out.println("The given path is a file.");
System.out.println("Size of file: " + f.length());
}
else if (f.isDirectory()) {
System.out.println("The given path is a Directory.");
System.out.println("Files in Directory are: ");
File[] list = f.listFiles();
for (File ff : list) {
System.out.println(list);
}
}
}
}