By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,975 Members | 617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,975 IT Pros & Developers. It's quick & easy.

Retrieve Binary data

P: 35
This is how i insert binary data to a binary file:
-> fingerprint is a BitSet format
Expand|Select|Wrap|Line Numbers
  1. File binFile = new File("BinaryFp.txt");
  2. FileOutputStream output = new FileOutputStream (binFile);
  3. DataOutputStream data = new DataOutputStream (output);
  4. for(int j=0,len=1024;j<len;j++)
  5. {
  6.     boolean bit = fingerprint.get(j);            
  7.     data.writeBoolean(bit);                    
  8. }    
This is how i retrieve the binary data from the binary file:
-> fingerprint1 is also a BitSet format
Expand|Select|Wrap|Line Numbers
  1. FileInputStream input = new FileInputStream ("BinaryFp.txt");
  2. DataInputStream data = new DataInputStream (input);
  3. for(int j=0;j<1024;j++)    
  4. {
  5.     boolean bit = data.readBoolean();
  6.     fingerprint1.set(j,bit);
  7. }
However, i realised that the data inserted and the data retrieved is not the same. Can anyone tell why is the data different? Thanks~
Dec 21 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.