ackage rbtree; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; import java.util.Comparator; import java.util.Map; import java.util.stream.Collectors; public class Lista10 { public static void main(String[] args) { RBTree tree = new RBTree(new Comparator() { @Override public int compare(String s1, String s2) { return s1.compareTo(s2); } }); Map dictionary = readDictionary(); loadTree(tree,dictionary); Tester.runTests(tree); } private static Map readDictionary() { try { Map dictionary = Files.readAllLines(Paths.get("odmiany.txt"), Charset.defaultCharset()) .stream() .collect(Collectors.toMap( (s) -> s.split(",")[0].trim(), (s) -> Arrays.stream(s.split(",")).skip(1).map((s2) -> s2.trim()).toArray(String[]::new), (oldValue, newValue) -> oldValue) ); return dictionary; } catch (IOException e) { e.printStackTrace(); } return null; } private static void loadTree(RBTree tree, Map dictionary) { for(String key : dictionary.keySet()) { tree.insert(key,dictionary.get(key)); } } }