public class CombinationToOneFile {
public static void main(String[] args) throws IOException, ParseException {
//将所有文件合并到target.csv中
FileOutputStream afterFos = new FileOutputStream("d:/combination/before12/"
+ "target.csv");
OutputStreamWriter osw = new OutputStreamWriter(afterFos, "utf8");
BufferedWriter out= new BufferedWriter(osw);
//读取要合并的文件所在的文件夹
File file = new File("D:\before12");
String test[];
//读取该文件夹下面所有要合并的文件
test = file.list();
for (int i = 0; i < test.length; i++) {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(
"d:/before12/" + test[i]), "utf8"));
String r = br.readLine();
while (r != null) {
out.write(r);
out.newLine();
out.flush();
r = br.readLine();
}
}
}
}
最后
以上就是清脆鸵鸟最近收集整理的关于 将一个文件夹下的多个文件合并到一个文件中的全部内容,更多相关内容请搜索靠谱客的其他文章。
发表评论 取消回复