import java.io.FileReader;
import java.io.IOException;
public class ReadTextFile {
public static void main(String[] args) {
String filePath = "yourFileName.txt"; // Replace with the actual file path and name
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
System.err.println("Error reading the file: " + e.getMessage());
}
}
}
No comments:
Post a Comment