public static void main(String[] args) throws InterruptedException, FileNotFoundException {
File file = new File("C:\\Users\\ynadmin\\Desktop\\test.txt");
File file1 = new File("C:\\Users\\ynadmin\\Desktop\\test1.txt");
BufferedReader reader = null;
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file1), StandardCharsets.UTF_8));
StringBuilder sbf = new StringBuilder();
try {
reader = new BufferedReader(new FileReader(file));
String tempStr;
while ((tempStr = reader.readLine()) != null) {
sbf.append(tempStr);
bw.write(tempStr+","); // 将数据写入文件中
bw.newLine(); // 新建一个换行符
bw.flush();
}
reader.close();
bw.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}