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