Read characters with FileReader : FileReader « File Input Output « Java






Read characters with FileReader

  

import java.io.FileReader;

class DigitCounter {

  public static void main(String args[]) throws Exception {

    // Create a file reader
    FileReader fr = new FileReader(args[0]);

    // Read characters
    int i;
    while ((i = fr.read()) != -1) {
      System.out.println((char) i);

    }

    // Close file reader
    fr.close();
  }
}

   
    
  








Related examples in the same category

1.Create BufferedReader from FileReader and process lines from file
2.Text file viewerText file viewer
3.Read and copy with FileReader and FileWriter
4.Use FileReader and FileWriter
5.An InputStream backed by a Reader
6.Text File Test