title: How to convert byte array to long without using java.nio?
body: <p>I am implementing a reliable data transfer protocol. I need to pass the checksum which is long value to a receiver. I am not allowed to use java.nio. </p>
  
  <p>I know how to convert long to byte array as show below:</p>
  
  <pre><code>ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DataOutputStream dos = new DataOutputStream(baos);
  dos.writeLong(someLong);
  dos.close();
  byte[] longBytes = baos.toByteArray();
  </code></pre>
  
  <p>But how do I convert byte array to long without using java.nio? </p>