neatly convert byte[] to long[] in java
<p>i have an array of bytes which needs to be repackaged to an array of longs. the input byte array is of unknown size (roughly from 0 to a few hundred). the long array needs to come out <strong>right aligned</strong> ie the lowest index long should be padded with zeros and all others should be full of the input bytes:
. (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11) --> (xxxxb0b1b2b3, b4b5b6b7b8b9b10b11)  </p>

<p>where b1,b2 etc is a given byte.
i have a solution but it isnt very neat or readable:  </p>

<pre><code>// outArr has length (inArr.length+7)/8

for (int i = 0; i &lt; inArr.length ; i++) {     
    outArr[outArr.length - i/8 - 1] |= ((long)inArr[inArr.length - i - 1]) &lt;&lt; (i % 8) * 8;
    }
</code></pre>

<p>is there a less ugly way of doing this?</p>