diff --git a/src/main/java/de/joethei/hs/java2/praktikum/praktikum4/KlausurenServer.java b/src/main/java/de/joethei/hs/java2/praktikum/praktikum4/KlausurenServer.java index 67cf11e..802872b 100644 --- a/src/main/java/de/joethei/hs/java2/praktikum/praktikum4/KlausurenServer.java +++ b/src/main/java/de/joethei/hs/java2/praktikum/praktikum4/KlausurenServer.java @@ -48,35 +48,17 @@ public class KlausurenServer { ConcurrentMap> set = new ConcurrentHashMap<>(data); Set> result = new HashSet<>(); - set.forEach((key, value) -> { - set.forEach((s, integers) -> { - if(!value.equals(integers)) { - if (integers.containsAll(value)) { - set.remove(key); - } + set.forEach((key, value) -> set.forEach((s, integers) -> { + if(!value.equals(integers)) { + if (integers.containsAll(value)) { + set.remove(key); } - }); - }); - - set.forEach((key, value) -> { - result.add(value); - }); - - /* - data.forEach((key, value) -> { - result.forEach(integers -> { - if(!integers.containsAll(value)) { - result.add(integers); - } - }); - }); - */ - Iterator> iterator = result.iterator(); - while (iterator.hasNext()) { - if(iterator.next().isEmpty()) { - iterator.remove(); } - } + })); + + set.forEach((key, value) -> result.add(value)); + + result.removeIf(TreeSet::isEmpty); writer.write(result.toString().substring(1, result.toString().length()-1).replace(" ", "")); } else { @@ -138,7 +120,7 @@ public class KlausurenServer { } catch (FileNotFoundException e) { e.printStackTrace(); } - try (BufferedReader br = new BufferedReader(fileReader)) { + try (BufferedReader br = new BufferedReader(Objects.requireNonNull(fileReader))) { for (String line = br.readLine(); line != null; line = br.readLine()) { TreeSet set = new TreeSet<>(); String[] array = line.split(":"); diff --git a/src/main/resources/praktikum3/vorlesungen-db.txt b/src/main/resources/praktikum3/vorlesungen-db.txt index 5fbff2c..59b11ad 100644 --- a/src/main/resources/praktikum3/vorlesungen-db.txt +++ b/src/main/resources/praktikum3/vorlesungen-db.txt @@ -1,4 +1,4 @@ -A1:Relativitätstheorie:Einstein:15 +A1:Relativitätstheorie:Einstein:15 B2:Quantenmechanik:Heisenberg:17 C2:Quantenphysik:Planck:5 T4:Thermodynamik:Kelvin:78