Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
DataInputStream dis = new DataInputStream(
  new FileInputStream("data.txt"));  // Little-endian data might be read as big-endian
int serialNumber = dis.readInt();

...

Code Block
bgColor#ccccff
	 
DataInputStream dis = new DataInputStream(
  new FileInputStream("data.txt"));

byte[] buffer= new byte[4];
int bytesRead = dis.read(buffer);  // Bytes are read into buffer
int serialNumber = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getInt();

...