Here you can find the source of mergeFiles(List
public static void mergeFiles(List<Path> files, Path mergedFile) throws IOException
//package com.java2s; //License from project: LGPL import java.io.IOException; import java.nio.channels.FileChannel; import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.List; public class Main { public static void mergeFiles(List<Path> files, Path mergedFile) throws IOException { try (FileChannel out = FileChannel.open(mergedFile, StandardOpenOption.APPEND, StandardOpenOption.WRITE)) { for (Path path : files) { try (FileChannel in = FileChannel.open(path, StandardOpenOption.READ)) { for (long p = 0, l = in.size(); p < l;) p += in.transferTo(p, l - p, out); }//from w ww .jav a2s. c o m } } catch (IOException e) { throw e; } } }