title: ByteBuffer switch endianness
body: <p>I am trying to switch endianess of <em>ByteBuffer</em>, but there is no effects from it. What am doing wrong?
  Maybe my debug main function is incorrect?</p>
  
  <pre><code>@Override
  public byte[] toBytes(BigDecimal type) {
      int octets = getOctetsNumber();
      BigInteger intVal = type.unscaledValue();
  
      byte[] temp = intVal.toByteArray();
      int addCount = octets - temp.length;
  
      //        DEBUG
      ByteBuffer buffer = ByteBuffer.allocate(octets);
      for(byte b: intVal.toByteArray()){
          buffer.put(b);
      }
      if (addCount &gt; 0){
          for (; addCount &gt; 0; addCount--) {
              buffer.put((byte)0x00);
          }
      }
      buffer.flip();
  
      buffer.order( ByteOrder.BIG_ENDIAN);
  
      return buffer.array();
  }
  
  public static void main(String[] arg) {
      IntegerDatatype intVal = new IntegerDatatype(17);
      BigDecimal bd = new BigDecimal(32000);
  
      byte[] bytes = intVal.toBytes(bd);
      String out = new String();
      for (byte b : bytes) {
          out += Integer.toBinaryString(b &amp; 255 | 256).substring(1) + " ";
      }
      System.out.println(out);
  }
  </code></pre>
  
  <p>main function prints this binary string : 01111101 00000000 00000000 00000000 
  but must prints: 00000000 10111110 00000000 00000000</p>