Use a FileReader to display a text file in Java
Description
The following code shows how to use a FileReader to display a text file.
Example
//from w ww.jav a 2 s . co m
import java.io.FileReader;
public class Main {
public static void main(String[] argv) throws Exception {
FileReader fr = new FileReader("text.txt");
int ch;
do {
ch = fr.read();
if (ch != -1)
System.out.println((char) ch);
} while (ch != -1);
fr.close();
}
}