• Post Reply Bookmark Topic Watch Topic
  • New Topic

"filter" application to convert a file from bigendian to little endian  RSS feed

 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have some legacy data that was created in the '90s under Solaris that I need to convert to little endian for input into other applications that run under Windows XP. The data are just a lot of shorts.

I hope that I might be able to use a bytebuffer, set it as big endian, read the data, then set it as little endian and write the data repeating until all the data are read (omitting details here).

Before I try it does anyone know if this will work? Otherwise do I need to read it into an array, convert, and then write? Or???

Thanks
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming your shorts are two byte integers. All you need to do then is read two bytes, reverse them, and write them out. Use buffered input and output streams and you won't even have to worry about managing the byte buffer yourself.
 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works - I think!!
Now I need to peek at the first two bytes in the files to confirm the swap. Since this is only going to be used one time to convert a bunch files I don't want to spend too much time on it.

Nate

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!