import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.nio.charset.Charset; public class FileReaderTest { public static void main(String[] args) { try { var fr = new FileReader("FileReaderTest.java"); { var cbuf = new char[1024]; var hasRead = 0; while ((hasRead = fr.read(cbuf)) > 0){ System.out.println(new String(cbuf, 0, hasRead)); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }