First page Back Continue Last page Overview Graphics
Example 1: Typing a text file
import java.io.*;
public class MyTextType {
public static void main(String[] args){
- try{
- FileReader fileIn= new FileReader("temp.txt");
- int c;
- while((c=fileIn.read()) != -1)
- System.out.print((char)c);
- fileIn.close();
- }catch(FileNotFoundException fnfe){
- System.err.println("file temp.text not found!!!");
- }catch (IOException ioe){
System.err.println("error reading from file!");
}