Convert C# method to Java
<p>I am looking to convert the following bit of C# code to Java. I having a hard time coming up with a equivalent.</p>

<h2>Working C# Code:</h2>

<pre><code>private ushort ConvertBytes(byte a, byte b, bool flip)
{
    byte[] buffer = new byte[] { a, b };
    if (!flip)
    {
        return BitConverter.ToUInt16(buffer, 0);
    }
    ushort num = BitConverter.ToUInt16(buffer, 0);
    //this.Weight = num;
    int xy = 0x3720;
    int num2 = 0x3720 - num;
    if (num2 &gt; -1)
    {
        return Convert.ToUInt16(num2);
    }
    return 1;
}
</code></pre>

<p>Here is the Java Code that does not work. The Big challenge is the "BitConverter.ToInt16(buffer,0). How do i get the Java equal of the working C# method.</p>

<h2>Java Code that is Wrong:</h2>

<pre><code>private short ConvertBytes(byte a, byte b, boolean flip){
    byte[] buffer = new byte[] { a, b };
    if (!flip){
        return  (short) ((a &lt;&lt; 8) | (b &amp; 0xFF));
    }
    short num = (short) ((a &lt;&lt; 8) | (b &amp; 0xFF));
    //this.Weight = num;
    int num2 = 0x3720 - num;
    if (num2 &gt; -1){
        return (short)num2;
    }
    return 1;
}
</code></pre>
