Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Program to convert Hexadecimal to its Character equivalent

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Program to convert Hexadecimal to its Character equivalent

    Hey all!

    I have a problem lol.

    I am trying to convert a hexadecimal value to its character equivilent.

    The specific task is a school assignment and I am very open about this. I need to import a file which contains the contents of the said hexadecimal values, read the file and display the characters on the screen.

    I have EVERYTHING done except fot the actual conversion lol. I have the import, printing even the loops to read the file from start to finish. All I need now is to know how to actually do the conversion lol. Is there an easy way to do this?

    So my simple question is this.

    String fileContents = 004e
    //convert the file contents here
    Println(character)

    finished.

    How can this be done?
    \
    Thanks all!!!


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Converting Hexadecimal to Char

    Hello nathanernest and welcome to the Java Programming Forums

    To convert the fileContents String to its corresponding character value, you will probably need a load of 'if' statements.

    Can you please post the code you have so far, including the file it reads and I will take a look.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Converting Hexadecimal to Char

    Here is an example:

    String fileContents = 004e
     
    if(fileContents.equals("004e")){
    System.out.println("E")
    }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. How to convert GSM 6.10 wav file to MP3/PCM/OGG/AU format using JAVA?
    By expertise in forum Java ME (Mobile Edition)
    Replies: 4
    Last Post: April 11th, 2014, 02:13 AM
  2. Hexadecimal answer rather than decimal
    By Eric in forum Java Theory & Questions
    Replies: 1
    Last Post: June 22nd, 2009, 11:36 AM
  3. [SOLVED] Java program to convert and compare integers
    By luke in forum What's Wrong With My Code?
    Replies: 9
    Last Post: May 18th, 2009, 06:26 PM
  4. Replies: 4
    Last Post: May 1st, 2009, 03:32 PM
  5. Java program to find the minimum and maximum values of input data
    By awake77 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 20th, 2008, 05:12 PM