File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes DataInputStream/ByteArrayInputStream/Binary Data and Encoding/Decoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "DataInputStream/ByteArrayInputStream/Binary Data and Encoding/Decoding" Watch "DataInputStream/ByteArrayInputStream/Binary Data and Encoding/Decoding" New topic
Author

DataInputStream/ByteArrayInputStream/Binary Data and Encoding/Decoding

Muhammad Asif
Ranch Hand

Joined: Jul 13, 2001
Posts: 202
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

DataInputStream dis = DataInputStream(ByteArrayInputStream(byteArray);

while ( (myfloat = dis.readFloat()) != -1){
// Built myfloat list
}


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.
DataInputStream dis1 = new DataInputStream(new File(fileName));

while ( (myfloat2 = dis1.readFloat()) != -1){
//build myfloat2 list
}

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,


SCJP, SCBCD, SCWCD 1.4, IBM-OOAD, SCEA, TCP, TCSS, TCIS, ATCP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataInputStream/ByteArrayInputStream/Binary Data and Encoding/Decoding