public static void concat(Iterable<File> toMerge,File dst) throws IOException {
  try (FileChannel dstChannel=FileChannel.open(dst.toPath(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE)){
    for (    File file : toMerge) {
      try (RandomAccessFile raf=new RandomAccessFile(file,"r")){
        FileChannel channel=raf.getChannel();
        dstChannel.write(channel.map(FileChannel.MapMode.READ_ONLY,0,raf.length()));
      }
     }
  }
 }

public static void concat ( Iterable < File > toMerge , File dst ) throws IOException { try ( FileChannel dstChannel = FileChannel . open ( dst . toPath ( ) , StandardOpenOption . CREATE , StandardOpenOption . TRUNCATE_EXISTING , StandardOpenOption . WRITE ) ) { for ( File file : toMerge ) { try ( RandomAccessFile raf = new RandomAccessFile ( file , "r" ) ) { FileChannel channel = raf . getChannel ( ) ; dstChannel . write ( channel . map ( FileChannel . MapMode . READ_ONLY , 0 , raf . length ( ) ) ) ; } } } }
concats the first files and writes them to the last file .
