Retrieve Binary data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • huiling25
    New Member
    • Dec 2006
    • 35

    #1

    Retrieve Binary data

    This is how i insert binary data to a binary file:
    -> fingerprint is a BitSet format
    Code:
    File binFile = new File("BinaryFp.txt");
    FileOutputStream output = new FileOutputStream (binFile);
    DataOutputStream data = new DataOutputStream (output);
    for(int j=0,len=1024;j<len;j++)
    {
    	boolean bit = fingerprint.get(j);			
    	data.writeBoolean(bit);					
    }
    This is how i retrieve the binary data from the binary file:
    -> fingerprint1 is also a BitSet format
    Code:
    FileInputStream input = new FileInputStream ("BinaryFp.txt");
    DataInputStream data = new DataInputStream (input);
    for(int j=0;j<1024;j++)	
    {
    	boolean bit = data.readBoolean();
    	fingerprint1.set(j,bit);
    }
    However, i realised that the data inserted and the data retrieved is not the same. Can anyone tell why is the data different? Thanks~
Working...