FilesConcatenator { public static byte[] concat(List<Path> filePathToConcatenate) { try (ByteArrayOutputStream bOutput = new ByteArrayOutputStream()) { filePathToConcatenate.stream() .forEach(path -> writeConcatInOutput(bOutput,path)); return bOutput.toByteArray(); } catch (IOException e) { throw new GenerationException("Error while content generating ", e); } }  static byte[] concat(List<Path> filePathToConcatenate);  }
@Test public void should_concatenate_files() throws IOException { Files.write("file1".getBytes(), temporaryFolder.newFile("file1.js")); Files.write("file2".getBytes(), temporaryFolder.newFile("file2.js")); List<Path> files = Arrays.asList(temporaryFolder.toPath().resolve("file1.js"), temporaryFolder.toPath() .resolve("file2.js")); byte[] content = FilesConcatenator.concat(files); assertThat(content).isEqualTo("file1file2".getBytes()); }