@Test void testCreateWordList() throws IOException { String sampleWordSet = "Saitama\n"; sampleWordSet += "Gumma\n"; sampleWordSet += "Gifu\n"; Set<String> result = WORD_LIST.load(new ByteArrayInputStream(sampleWordSet.getBytes(StandardCharsets.UTF_8))); assertEquals(3, result.size()); }
E load(InputStream inputStream) throws IOException { E e = supplier.get(); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { bufferedReader.lines().forEach(line -> loader.accept(e, line)); } return e; }
DictionaryLoader { E load(InputStream inputStream) throws IOException { E e = supplier.get(); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { bufferedReader.lines().forEach(line -> loader.accept(e, line)); } return e; } }
DictionaryLoader { E load(InputStream inputStream) throws IOException { E e = supplier.get(); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { bufferedReader.lines().forEach(line -> loader.accept(e, line)); } return e; } DictionaryLoader(Supplier<E> supplier, BiConsumer<E, String> loader); }
DictionaryLoader { E load(InputStream inputStream) throws IOException { E e = supplier.get(); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { bufferedReader.lines().forEach(line -> loader.accept(e, line)); } return e; } DictionaryLoader(Supplier<E> supplier, BiConsumer<E, String> loader); E loadCachedFromResource(String path, String dictionaryName); E loadCachedFromFile(File file, String dictionaryName); }
DictionaryLoader { E load(InputStream inputStream) throws IOException { E e = supplier.get(); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { bufferedReader.lines().forEach(line -> loader.accept(e, line)); } return e; } DictionaryLoader(Supplier<E> supplier, BiConsumer<E, String> loader); E loadCachedFromResource(String path, String dictionaryName); E loadCachedFromFile(File file, String dictionaryName);  }