Converting Integer to byte array in java giving a diff value
<ul>
<li><p>Im trying to convert an integer of size 4 to byte array but its
giving me strange value.</p>

<pre><code> byte[] bytes1 = my_int_to_bb_le(196,4);
   public static  byte[] my_int_to_bb_le(int myInteger,int length)
   {
     return ByteBuffer.allocate(length).order(ByteOrder.LITTLE_ENDIAN).putInt(myInteger).array();
   }     
</code></pre></li>
<li><p>output : 
-60 0 0 0</p></li>
<li><p>required output as : 196 0 0 0</p>

<p>Tried the alternate this code but not working as its giving the same
output</p>

<pre><code>public static byte[] convertIntByteArray(int intval,int len)     
{       
   byte[] intarray = new byte[len];          

   for(int i=0;i&lt;len;i++)        
   {
       if(i==0)
       {
           intarray[i]=(byte)intval;
       }
       else
           intarray[i]=0;        
    } 
    return intarray;     
}
</code></pre></li>
<li><p>output : -60 0 0 0</p></li>
<li><p>required output as : 196 0 0 0</p>

<p>Thanks</p></li>
</ul>
