package com.Work5;
import org.junit.Test;
import java.io.*;
public class Five {
@Test
public void test01() {
for (int i = 1; i < 4; i++) {
try {
marge(new File("G:\\文件"+ "\\" + i + ".txt"), new File("G:\\新建文本文档.txt"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void marge(File file,File files) throws IOException {
InputStream input = null;
OutputStream output = null;
input = new FileInputStream(file);
byte [] bytes = new byte[1024];
output = new FileOutputStream(files,true);
int len;
while((len = input.read(bytes)) != -1){
output.write(bytes,0,len);
}
}
}