Long mac address back to byte array
<p>I have a method that takes a mac address from a string and converts it to a byte array. Then I have another method take that byte array and convert it to a long. As Follows</p>

<pre><code>final long address = ((long)addr[5] &amp; 0xff) 
    + (((long)addr[4] &amp; 0xff) &lt;&lt; 8) 
    + (((long)addr[3] &amp; 0xff) &lt;&lt; 16) 
    + (((long)addr[2] &amp; 0xff) &lt;&lt; 24) 
    + (((long)addr[1] &amp; 0xff) &lt;&lt; 32) 
    + (((long)addr[0] &amp; 0xff) &lt;&lt; 40);
</code></pre>

<p>However I cannot figure out how to convert this long back into a byte array for storage.</p>

<p>I have tried</p>

<pre><code>/* long l = mac in long format address | mac addresses only take 6 bytes */
buffer[currentOffset++] = (byte)l;
buffer[currentOffset++] = (byte)(l &gt;&gt; 8);
buffer[currentOffset++] = (byte)(l &gt;&gt; 16);
buffer[currentOffset++] = (byte)(l &gt;&gt; 24);
buffer[currentOffset++] = (byte)(l &gt;&gt; 32);
buffer[currentOffset++] = (byte)(l &gt;&gt; 40);
</code></pre>

<p>It does not convert back correctly though.</p>
