title: Byte Order Conversion in Java for Network and Host order
body: <p>The topic is rather simple, but I might have confused myself a bit here. Network byte order is Big-Endian. Java by default uses Big-endian as well (as in the case of class files). My windows machine uses Intel processors, which are Little-Endian and windows itself also uses Little-Endian. So, if I uses a <code>java.nio.ByteBuffer.allocateDirect()</code>, then the default Endianness is Little-Endian (<em>because of the OS and/or the processor</em>), however, if I want to send this data on network, on reading data from  <code>ByteBuffer</code>, do I need to use <code>ByteBuffer.order(ByteOrder.BIG_ENDIAN)</code>? Additionally, Do i have to do the reverse while reading the data from a <code>Channel</code> to a <code>ByteBuffer</code>? I almost ignored it when using <code>java.io</code> package</p>
  
  <p>Another part of the question is also related to working on the machine itself. </p>
  
  <ol>
  <li>Should I always be aware of the Endianness of my host machine? So, whatever local data storage format is used, its fine within this machine's environment, however, convert the data to BIG_ENDIAN when sending to network.</li>
  <li>In terms of Endianness, for default file formats, say on windows, its always Little-Endian. However, now using the same file on a MAC or a Linux with Big-Endian, should I save it with a Byte-order-Marking (BOM)? </li>
  </ol>