Mittwoch lesson

This commit is contained in:
sageTheDM 2024-12-19 07:51:04 +01:00
parent e0efeb82ef
commit 8901dea11b
61 changed files with 663 additions and 0 deletions

View file

@ -0,0 +1,28 @@
import java.io.*;
public class App {
public static void main(String[] args) {
try {
readFile("test.txt");
} catch (FileNotFoundException e) {
System.err.println("Error: The file was not found. Please check the file path.");
} catch (IOException e) {
System.err.println("Error: An I/O error occurred while reading the file.");
} catch (Exception e) {
System.err.println("An unexpected error occurred: " + e.getMessage());
}
}
private static void readFile(String fileName) throws IOException {
FileReader f = new FileReader(fileName);
try {
int c;
while ((c = f.read()) != -1) {
System.out.print((char) c);
}
} finally {
f.close();
}
}
}