-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadFile.java
More file actions
22 lines (21 loc) · 753 Bytes
/
ReadFile.java
File metadata and controls
22 lines (21 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.io.File; // Import the File class
import java.io.FileNotFoundException; // Import this class to handle errors
import java.util.Scanner; // Import the Scanner class to read text files
public class ReadFile {
public static void read(String x) {
try {
File myObj = new File("/dzaky/Kuliah/Semester 3/pbo/Final Project/" + x);
Scanner myReader = new Scanner(myObj);
while (myReader.hasNextLine()) {
String data = myReader.nextLine();
System.out.println(data);
}
myReader.close();
} catch (FileNotFoundException e) {
System.out.println("Ada error nih, afaan tuh??");
e.printStackTrace();
}
}
public static void main(String[] args) throws FileNotFoundException {
}
}