1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import static java.lang.System.out
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.IOException
import java.nio.ByteBuffer
import java.nio.channels.FileChannel
import java.util.Arrays
public class test {
public static final int BUFSIZE = 1024 * 8
public static void mergeFiles(String outFile, String[] files) {
FileChannel outChannel = null
out.println("Merge " + Arrays.toString(files) + " into " + outFile)
try {
outChannel = new FileOutputStream(outFile).getChannel()
for(String f : files){
FileChannel fc = new FileInputStream(f).getChannel()
ByteBuffer bb = ByteBuffer.allocate(BUFSIZE)
while(fc.read(bb) != -1){
bb.flip()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)