package ReadTXT;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.*;
public class Filedo {
//逐行写入文本
public static void main(String[] args) throws IOException{
String filePath = "Data//test.txt";
readFile(filePath);
//writeFile(filePath);
}
public static final void writeFile(String str) throws IOException {
String filePath = "Data//output.txt";
FileWriter fw = null;
try {
fw = new FileWriter(filePath,true);
//String c = "abs"+"\r\n";
fw.write(str);
fw.close();
//fw.flush();
//readF1(filePath);
} catch (IOException e1) {
e1.printStackTrace();
System.out.println("写入失败");
System.exit(-1);
}
}
//逐行读取文本
public static final void readFile(String filePath) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(filePath)));
for (String line = br.readLine(); line != null; line = br.readLine()) {
//System.out.println(line);
if(!line.startsWith("A")){
writeFile(line);
System.out.println(line);
}
}
br.close();
}
}