9.Get all characters from the file and display on the screen
💡Code:
import java.io.FileReader;
import java.io.IOException;
public class ReadFileCharacters7078 {
public static void main(String[] args) {
// Replace "your_file_path" with the path to your text file
String filePath = "7078.txt";
try (FileReader reader = new FileReader(filePath)) {
int character;
while ((character = reader.read()) != -1) {
System.out.print((char) character);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
📸Output :