Converting file to Hex

I need to convert a file into hex after I have loaded it in using an I

Page 1 of 1

2 Replies - 3836 Views - Last Post: 06 April 2009 - 06:32 AM Rate Topic: -----

#1 cookie_272  Icon User is offline

  • New D.I.C Head

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

Converting file to Hex

Posted 05 April 2009 - 11: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

Is This A Good Question/Topic? 0
  • +

Replies To: Converting file to Hex

#2 Sentrosi  Icon User is offline

  • New D.I.C Head

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

Re: Converting file to Hex

Posted 05 April 2009 - 07: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

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

Re: Converting file to Hex

Posted 06 April 2009 - 06: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
  • +
  • -

Page 1 of 1