• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Writing Hex Values to a file

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I do have certain Hex values (For example A-41,B-42,C-43 etc).I want to write the hex values to a file through my java program and the file should contain A,B,C.

Any clues....

Thx in advance

Nikhil
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use a Formatter object to write the values, you can change the numbers to characters using a %c tag in the format() method. I think it only works in a text file; Formatter is the opposite of Scanner, so it is a basic and simple text writing device. But it works and is easy to use.

BTW. You don't have hex values. You have a number 00....00 0100 0001, for example, which might represent 41 in hex, or 65 in decimal, or 101 in octal, or 'A' as a char. Or even 00....00 0100 0001 in any of the Java integer number primitive formats. You char type is only a number which is displayed as a character. So you can display the same number in all sorts of different format.
reply
    Bookmark Topic Watch Topic
  • New Topic