All Downloads are FREE. Search and download functionalities are using the official Maven repository.

openjdk21.openjdk17.tests.data.utf-8-by-default.FileReaderExample Maven / Gradle / Ivy

The newest version!
import java.io.FileReader;

class FileReaderExample {
  public static void main(String[] args) {

    // Creates an array of character
    char[] array = new char[100];

    try {
      // Creates a reader using the FileReader
      FileReader input = new FileReader("input.txt");

      // Reads characters
      input.read(array);
      System.out.println("Data in the file: ");
      System.out.println(array);

      // Closes the reader
      input.close();
    }

    catch(Exception e) {
      e.getStackTrace();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy