• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing Hex Values to a file  RSS feed

 
Nikhil Bansal
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!