You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 6, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 6, 2026. It is now read-only.
Activity
[-]import java.io.*; public class ReadFileExample { public static void main(String[] args) { String fileName = "example.txt"; try { BufferedReader reader = new BufferedReader(new FileReader(fileName)); String line; System.out.println("Contents of the file:\n"); while ((line = reader.readLine()) != null) { System.out.println(line); } reader.close(); } catch (FileNotFoundException e) { System.out.println("File not found: " + fileName); } catch (IOException e) { System.out.println("Error reading file: " + e.getMessage()); } } }[/-][+]File [/+]sowtheesh61-tech commentedon Nov 1, 2025
import java.io.*;
public class ReadFileExample {
public static void main(String[] args) {
String fileName = "example.txt";
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String line;
System.out.println("Contents of the file:\n");
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
}