BufferReader BufferWriter
Copying information from one file to another with 'BufferReader BufferWriter'
public class Demo5 {
public static void main(String[] args) {
//data cache
try {
FileReader fileReader = new FileReader("C:/Users/caich5/Desktop/aaaa.txt");
FileWriter fileWriter = new FileWriter("C:/Users/caich5/Desktop/bbbb.txt");
BufferedReader reader = new BufferedReader(fileReader);
BufferedWriter writer = new BufferedWriter(fileWriter);
String line = null;
while((line=reader.readLine())!= null){
writer.write(line);
writer.newLine();
writer.flush();
}
writer.close();
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aimer,c'est partager