Java:
import java.io.*;
public class Blablubb {
public static void main(String[] args) {
String fn = "xyz.txt";
FileInputStream input = null;
try {
input = new FileInputStream(fn);
System.out.println("\nDatei " + fn + " geoeffnet!");
int aValue = 0;
while (true) {
aValue = input.read();
if (aValue == -1 ) {
System.out.println("<EOF>");
throw(new EOFException()); // Wenn beim Lesen aus einem Stream,das Ende erreicht wurde
}
else System.out.print((char)aValue);
}
}
catch (IOException e) {}
finally {
if (input != null) {
input.close();
System.out.println("\nDatei " + fn + " geschlossen!");
}
}
}
}
Ich wollte mal diskutieren was beim Exception Handling besonders schlechter Stil ist bzw. was man vermeiden sollte. Natürlich bezogen auf das Beispiel