Slip No 26 Q A

Q.Write a java program to display ASCII values of the characters from a file.[15 M]

import java.io.*;

class ASCIIFile
{
    public static void main(String args[]) throws IOException
    {
        FileReader fr = new FileReader("input.txt");

        int ch;

        System.out.println("Character\tASCII Value");

        while((ch = fr.read()) != -1)
        {
            char c = (char) ch;
            System.out.println(c + "\t\t" + ch);
        }

        fr.close();
    }
}
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top