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();
}
}
}
}
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();
}
}
}
}