About Question enthuware.ocpjp.v17.2.3756 :
Posted: Sun Feb 09, 2025 5:49 am
why this works with FileReader i learned that this way works only with BufferedReader
Code: Select all
char[] buf = new char[5];
try(FileReader fr = new FileReader("C:\\Users\\Downloads\\test1.txt");
FileWriter fw = new FileWriter("C:\\Users\\Downloads\\test2.txt")){
int count = 0;
while( (count = fr.read(buf)) != -1){
fw.write(buf, 0, count);
}
}