第一种方法:
public static void files() {
try {
java.io.File file = new java.io.File("123.txt");
java.io.FileOutputStream fos = new java.io.FileOutputStream(file);
FileInputStream fis = new FileInputStream(new File("haha.txt"));
FileInputStream fis1 = new FileInputStream(new File("abc.txt"));
SequenceInputStream sis = new SequenceInputStream(fis, fis1);
byte[] b = new byte[1];
while ((sis.read(b)) != -1) {
fos.write(b);
}
fos.flush();
System.out.println("success!");
} catch (Exception e) {
System.out.println("error: " + e);
}
}
还有就是利用文件追加的方法合并