1个回答
展开全部
JAVA的问题干嘛发C/C++这边额 = =
-----------------------华丽的分割线-----------------------------
File srcFile1 = new File("1.txt");
File srcFile2 = new File("2.txt");
File destFile = new File("3.txt");
if (destFile.exists()) {
destFile.delete();
destFile.createNewFile();
} // 如果不希望覆盖原文件,就不要上面这步
FileInputStream in = null;
FileOutputStream out = null;
try {
out = new FileOutputStream(destFile);
int byteRead = 0;
byte[] buffer = new byte[100]; //这里的100是每次读多大的数据,随便定
in = new FileInputStream(srcFile1);
while ((byteRead = in.read(buffer)) != -1) {
out.write(buffer, 0, byteRead);
}
in.close();
in = new FileInputStream(srcFile2);
while ((byteRead = in.read(buffer)) != -1) {
out.write(buffer, 0, byteRead);
}
out.flush();
} catch (IOException e) {
e.printStachTrace();
} finally {
if (in != null) {
in.close();
in = null;
}
if (out != null) {
out.close();
out = null;
}
}
-----------------------华丽的分割线-----------------------------
File srcFile1 = new File("1.txt");
File srcFile2 = new File("2.txt");
File destFile = new File("3.txt");
if (destFile.exists()) {
destFile.delete();
destFile.createNewFile();
} // 如果不希望覆盖原文件,就不要上面这步
FileInputStream in = null;
FileOutputStream out = null;
try {
out = new FileOutputStream(destFile);
int byteRead = 0;
byte[] buffer = new byte[100]; //这里的100是每次读多大的数据,随便定
in = new FileInputStream(srcFile1);
while ((byteRead = in.read(buffer)) != -1) {
out.write(buffer, 0, byteRead);
}
in.close();
in = new FileInputStream(srcFile2);
while ((byteRead = in.read(buffer)) != -1) {
out.write(buffer, 0, byteRead);
}
out.flush();
} catch (IOException e) {
e.printStachTrace();
} finally {
if (in != null) {
in.close();
in = null;
}
if (out != null) {
out.close();
out = null;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询