62,634
社区成员
发帖
与我相关
我的任务
分享
package com.wsb.test;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileCopyChangeContext {
public static void main(String[] args){
try {
File file1 = new File("d:\\3.txt");
File file2 = new File("d:\\4.txt");
if (!file2.exists())
file2.createNewFile();
FileReader reader = new FileReader(file1);
FileWriter writer = new FileWriter(file2);
int a;
char b;
while ((a = reader.read()) != -1) {
b = (char) a;
if (!(b == ',')) {
writer.write(a);
}
}
reader.close();
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
1张三
2李四
3AA
4BB