-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleFile.java
More file actions
32 lines (28 loc) · 1.02 KB
/
SampleFile.java
File metadata and controls
32 lines (28 loc) · 1.02 KB
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
import java.io.*;
//import java.util.Scanner;
public class SampleFile {
public static void main(String[] args) {
try {
File myText = new File("ListOfStudents.txt");
//Scanner myScan = new Scanner(myText);
if (myText.exists()) {
System.out.println("The file is already created.");
System.out.println("File Name: " + myText.getName());
System.out.println("File Absolute Path: " + myText.getAbsolutePath());
System.out.println("File Size: " + myText.length() + " bytes");
System.out.println("Readable: " + myText.canRead());
System.out.println("Writeable: " + myText.canWrite());
/*
while (myScan.hasNextLine())
System.out.println(myScan.nextLine());
*/
//myScan.close();
}
else
System.out.println("The file is not yet created.");
}
catch (Exception e) {
e.printStackTrace();
}
}
}