0

I think the order it wrote with a randomAccessFile doesn't match with the order it read. How do I correct this? Is it something to do with Big/Little Endian?

RandomAccessFile accessor = new RandomAccessFile (new File("passwd_file"), "rws");   
accessor.write(macbytes);
//System.out.println(macbytes);
byte[] test=new byte[(int) accessor.length()];
accessor.seek(0);
accessor.read(test);

//System.out.println(test);
if (test.equals(macbytes))System.out.println("true");
else System.out.println("false");
Kara
  • 6,115
  • 16
  • 50
  • 57
Ava
  • 9
  • 1

1 Answers1

2

Your test is invalid. The byte[] class does not override Object.equals(). Try using Arrays.equals().

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Thank you SO MUCH. I've been checking this for hours and always thought it was something to do with the class type and never thought about it has anything to do with the equals... Sorry I guess I am not experienced.. – Ava Apr 23 '17 at 15:15