This commit is contained in:
louiscklaw
2025-01-31 19:15:17 +08:00
parent 09adae8c8e
commit 6c60a73f30
1546 changed files with 286918 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import java.util.*;
import java.io.*;
public class ReadTextFile {
public static void main(String[] args) {
String filename = "";
String line;
try {
filename = args[0];
Scanner fin = new Scanner(new File(filename));
while (fin.hasNextLine()) {
line = fin.nextLine();
System.out.println(line);
}
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Usage: java ReadTextFile <filename>");
} catch (FileNotFoundException e) {
System.out.println("Failed to open file " + filename);
}
}
}