Hallo,
für eine Hausuaufgabe muss ich ein "Labyrinth" in einem Terminal erstellen. Die Größe,Breite, Länge des Labyrinths sind in einer properties Datei abgespeichert. Aber wenn ich versuche die Datei einzulesen, sehe ich nichts im Terminal.
Ich habe bis jetzt folgendes geschrieben:
Ich habe verschiedene Lösungen online gefunden, aber nichts scheint wirklich zu funktionieren.
Vielen Dank für die Hilfe!
für eine Hausuaufgabe muss ich ein "Labyrinth" in einem Terminal erstellen. Die Größe,Breite, Länge des Labyrinths sind in einer properties Datei abgespeichert. Aber wenn ich versuche die Datei einzulesen, sehe ich nichts im Terminal.
Ich habe bis jetzt folgendes geschrieben:
Java:
public static void main(String[] args) throws FileNotFoundException, IOException {
Terminal terminal = TerminalFacade.createSwingTerminal();
terminal.applyForegroundColor(Terminal.Color.RED);
terminal.enterPrivateMode();
Properties prop = new Properties();
InputStream input = null;
try {
String filename = "level_small.properties";
input = Capstone.class.getClassLoader().getResourceAsStream(filename);
if(input==null){
System.out.println("Sorry, unable to find " + filename);
return;
}
prop.load(input);
//Werte erhalten und ausdrucken
System.out.println(prop.getProperty("Width"));
System.out.println(prop.getProperty("Height"));
System.out.println(prop.getProperty("NrIn"));
System.out.println(prop.getProperty("NrOut"));
System.out.println(prop.getProperty("StaticTraps"));
System.out.println(prop.getProperty("DynamicTraps"));
} catch (IOException ex) {
ex.printStackTrace();
} finally{
if(input!=null){
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
terminal.exitPrivateMode();
}
}
Vielen Dank für die Hilfe!
Zuletzt bearbeitet von einem Moderator: