@Test void simpleCreateTest() throws IOException { Output output = new Output("simple", "This is a simple test."); FileConsumer fileConsumer = new FileConsumer(tempDir); fileConsumer.consumeOutput(Collections.singletonList(output)); Path expectedFilePath = Paths.get(tempDir.toString(), output.getName()); assertThat(expectedFilePath.toFile().exists()).isTrue(); assertThat(Files.readAllLines(expectedFilePath)) .isEqualTo(Collections.singletonList(output.getData())); }
@Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } FileConsumer(Path directory);  FileConsumer(@NonNull Path directory, FileOutputStreamProvider fileOutputStreamProvider); }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } FileConsumer(Path directory);  FileConsumer(@NonNull Path directory, FileOutputStreamProvider fileOutputStreamProvider); @Override void consumeOutput(List<Output> outputs); }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } FileConsumer(Path directory);  FileConsumer(@NonNull Path directory, FileOutputStreamProvider fileOutputStreamProvider); @Override void consumeOutput(List<Output> outputs);  }