Write a java program to display ASCII values of the characters from a file.
import
java.io.FileInputStream;
import
java.io.IOException;
public class
FileASCIIValues {
public static void main(String[] args) {
String fileName =
"your_file.txt"; // Replace with the actual file path
try (FileInputStream fileInputStream =
new FileInputStream(fileName)) {
int character;
while ((character =
fileInputStream.read()) != -1) {
System.out.println("Character: " + (char) character + " |
ASCII Value: " + character);
}
}
catch (IOException e) {
System.err.println("An error
occurred while reading the file.");
e.printStackTrace();
}
}
}