• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataInputStream/ByteArrayInputStream/Binary Data and Encoding/Decoding

 
Muhammad Asif
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am facing a strange sort of issue.

I have some binary data (consisting of a set of floating point numbers), which i am encoding using Base64.encode to convert to a Character.

I put the data in some temporary storage(DB), and getting it back for processing.

When i get the string back, i decode it back using Base64.decode, and get a byteArray.

In order to read the float data, i am using




The data that i am getting using the above code, and the data which i get using directly reading from the file, is totally different.


The data in myfloat and myfloat2 list is entirely different.

Am i doing something really stupid here ?

P.S. I haven't touched Java for last 6 years, so kind of rusty at the moment! I will get there slowly but surely
Regards,

 
Arun garnet
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know it's very late.
But, did you find the solution for this?
 
Campbell Ritchie
Sheriff
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Don't know but now you have posted, this thread will come to people's attention and you might get a response.
 
Stephan van Hulst
Bartender
Posts: 6337
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the original post, the only way the data can be different in these two cases is simply that the data in the array doesn't match the data in the file.

Arun, you should post the relevant part of the code you are working on so we can see what's wrong. Please provide your own problem description as well.

Note that nowadays Java has the Base64 class which has encoders and decoders that you can wrap around a stream.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic