public static long merge ( final Collection < File > sourceFiles , final File destFile ) throws UncheckedIOException { final byte [ ] buf = Objectory . createByteArrayBuffer ( ) ; long totalCount = 0 ; OutputStream output = null ; try { output = new FileOutputStream ( destFile ) ; InputStream input = null ; for ( File file : sourceFiles ) { try { input = new FileInputStream ( file ) ; int count = 0 ; while ( EOF != ( count = read ( input , buf , 0 , buf . length ) ) ) { output . write ( buf , 0 , count ) ; totalCount += count ; } } finally { close ( input ) ; } } output . flush ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } finally { Objectory . recycle ( buf ) ; close ( output ) ; } return totalCount ; }
Merge the specified source files into the destination file .