im trying to read from a file using FileReader but the program goes in an infinite loop : here is my code:
import java.io.FileReader;
public class Test {
public static void main(String[] args) {
try(FileReader f = new FileReader("sales.dat");){
char ch = (char)f.read();
while(ch != -1){
ch = (char)f.read();
System.out.print(ch);
}
}catch (Exception e){
}
}
}
and why is it not efficient to read files using just FileReader and it's better to use a BufferedReader object