Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a Java Expert!

Join 416,731 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,917 people online right now.Registration is fast and FREE... Join Now!



Converting file to Hex I need to convert a file into hex after I have loaded it in using an I Rate Topic: -----

#1 cookie_272  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-April 09


Dream Kudos: 0

Share |

Converting file to Hex

Posted 05 April 2009 - 10:38 AM

Hi,

I have loaded my file into my program using an inputStreamReader like so:

try{
	  input = new InputStreamReader (new FileInputStream (path1), "UTF-16");
	}	
   catch (IOException e)
   {
	System.out.println("Error");
   }


This takes the file and converts it to UNICODE. If this is not the right method then if you could let me know thanks, but I think it is.

I then need to convert the file in to Hex. After looking around I can only find how to convert a String into Hex, is there anyway to covnvert the entire contents of the file into Hex?
If you need anymore information then let me know, but I think I have covered all the bases.

Thanks in advance for our help.

Cookie_272
Was This Post Helpful? 0
  • +
  • -


#2 Sentrosi  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 03-April 09


Dream Kudos: 0

Re: Converting file to Hex

Posted 05 April 2009 - 06:09 PM

Have you tried reading the contents of the file into a string (or array of strings) and then converting those to hex?
Was This Post Helpful? 0
  • +
  • -

#3 cookie_272  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-April 09


Dream Kudos: 0

Re: Converting file to Hex

Posted 06 April 2009 - 05:32 AM

View PostSentrosi, on 5 Apr, 2009 - 06:09 PM, said:

Have you tried reading the contents of the file into a string (or array of strings) and then converting those to hex?


I had thought about this as an option when I started my program. Would this still require the use of the InputStreamReader or not? Or is there a way to directly read the file into and array? I had planned to put the file into an array of strings later on.

Do you think my best method would be:
  • Load the file into the program using an InputStreamReader
  • Break the file up into srings to the lenght that I require (1024bytes)
  • Convert each part of the array into hex in a new array, so leaving my original array of strings intact for future modification

Thanks for your opinions.

cookie_272
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users