From http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Data/endian.html
For example: 90, AB, 12, CD where each byte requires 2 hex digits.
Big Endian (BE) / Little Endian (LE) are two ways to organize multi-byte words.
Big Endian
In big endian, you store the most significant byte in the smallest address.
Address | Value |
1000 | 90 |
1001 | AB |
1002 | 12 |
1003 | CD |
Little Endian
In little endian, you store the least significant byte in the smallest address.Address | Value |
1000 | CD |
1001 | 12 |
1002 | AB |
1003 | 90 |
http://mindprod.com/jgloss/endian.html
Java stores binary values internally and in files MSB (Most Significant Byte) first, i.e. high order part first. This is referred to as big-endian byte sex or sometimes network order. Java binary files, Java sockets and OpenType font files also use big-endian order.
Everything in Java binary format files is stored big-endian, MSB (Most Significant Bit) MSB first. This is sometimes called network order. This is good news. This means if you use only Java, all files are done the same way on all platforms.
We can check whether java.nio.ByteOrder.nativeOrder() is equal to ByteOrder.LITTLE_ENDIAN or ByteOrder.BIG_ENDIAN.
Which is Better?
Both formats have their advantages and disadvantages.
In "Little Endian" form, assembly language instructions for picking up a 1, 2, 4, or longer byte number proceed in exactly the same way for all formats: first pick up the lowest order byte at offset 0. Also, because of the 1:1 relationship between address offset and byte number (offset 0 is byte 0), multiple precision math routines are correspondingly easy to write.
In "Big Endian" form, by having the high-order byte come first, you can always test whether the number is positive or negative by looking at the byte at offset zero. You don't have to know how long the number is, nor do you have to skip over any bytes to find the byte containing the sign information. The numbers are also stored in the order in which they are printed out, so binary to decimal routines are particularly
http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Data/endian.html
Why is endianness so important? Suppose you are storing int values to a file, then you send the file to a machine which uses the opposite endianness and read in the value. You'll run into problems because of endianness. You'll read in reversed values that won't make sense.
Endianness is also a big issue when sending numbers over the network. Again, if you send a value from a machine of one endianness to a machine of the opposite endianness, you'll have problems. This is even worse over the network, because you might not be able to determine the endianness of the machine that sent you the data.
The solution is to send 4 byte quantities using network byte order which is arbitrarily picked to be one of the endianness (not sure if it's big or little, but it's one of them). If your machine has the same endianness as network byte order, then great, no change is needed. If not, then you must reverse the bytes.
Read full article from Dr. Bill's Notes on "Little Endian" vs. "Big Endian"