Methode verbessert wegen Fehler
parent
cb97bd32eb
commit
99f0b2627b
|
@ -8,20 +8,31 @@ import java.util.*;
|
|||
*/
|
||||
public class HitoriSolutionLoader {
|
||||
|
||||
/**
|
||||
* Loads solution coordinates from a CSV file.
|
||||
* @param filePath The path to the CSV file containing solution coordinates.
|
||||
* @return A list of "row,column" formatted solution coordinates.
|
||||
* @throws IOException If the file cannot be read.
|
||||
*/
|
||||
public static List<String> loadSolution(String filePath) throws IOException {
|
||||
public static List<String> loadSolution(String resourcePath) throws IOException {
|
||||
InputStream inputStream = HitoriSolutionLoader.class.getResourceAsStream(resourcePath);
|
||||
if (inputStream == null) {
|
||||
throw new IOException("Ressourcendatei nicht gefunden: " + resourcePath);
|
||||
}
|
||||
|
||||
List<String> solutionCoordinates = new ArrayList<>();
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line;
|
||||
boolean isSolutionSection = false;
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
solutionCoordinates.add(line.trim());
|
||||
// Erkenne den Abschnitt für die Lösung
|
||||
if (line.startsWith("//Lösung")) {
|
||||
isSolutionSection = true;
|
||||
continue; // Überspringe die Kommentarzeile
|
||||
}
|
||||
|
||||
if (isSolutionSection) {
|
||||
solutionCoordinates.add(line.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return solutionCoordinates;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue