-2
我有,我想在一個文件中合併它們的文件的數組。我用這個,但這不起作用
public static void joinf(File f1, File f2){
try{
InputStream in = new FileInputStream(f1);
OutputStream out = new FileOutputStream(f2,true);
byte[] buf = new byte[8192];
int len;
while ((len = in.read(buf)) > 0){
out.write(buf, 0, len);
}
in.close();
out.close();
System.out.println("File copied.");
}
catch(FileNotFoundException ex){
System.out.println(ex.getMessage() + " in the specified directory.");
System.exit(0);
}
catch(IOException e){
System.out.println(e.getMessage());
}
}
public void pro(File a,File[]b){
for(int i=0;i<b.length;i++){
joinf(a,b[i]);
}
http://stackoverflow.com/questions/14673063/merging-file-in-java – isvforall
請不要發佈[相同的問題](http://stackoverflow.com/q/14673063/335858)。 – dasblinkenlight
,因爲我沒有得到答案,所以我不得不分享它 – user1781384