Improve Byte Conversion in Java
<p>i need some help improving the following code - there is a conversion between byte and int, that does not work in all cases - I need some feedback to find and solve possible issues involving byteToInt IntToByte conversion</p>

<pre><code>int start = 02;
int stepSize = 256;
int bytesLeftToRead = 
// [0][1] encode a hex value as two bytes
// this part only works for [0] &gt; 0 and [0] &lt; 10 -- other restrictions?
response[0]*256 + Integer.parseInt(Integer.toHexString(response[1] + 256), 16);

while(bytesLeftToRead &gt; 0){

    // convert where to start from int to two bytes
    cmdReadPD[2] = (byte) (start / 256);
    cmdReadPD[3] = (byte) (start % 256);

    if(stepSize &gt; bytesLeftToRead){
        stepSize = bytesLeftToRead;
    }

    // encode stepsize in two bytes
    cmdReadPD[5] = (byte) (stepSize / 256);
    cmdReadPD[6] = (byte) (stepSize % 256);

    start += stepSize;
    bytesLeftToRead -= stepSize;
    read(cmdReadPD, stepSize);
}
</code></pre>
