title: Java equivalent of python's struct.unpack?
body: <p>Is there any function equivalent to <code>struct.unpack('&gt;h', buf)</code> in java that allows me to unpack values like this?</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>to unpack data in java we use :  <em>RandomAccessFile</em></p>
  
  <pre><code>    RandomAccessFile raf = new RandomAccessFile(filename, "rw");
  
      try{
          raf.seek(((i - 1) * 1201 + (j - 1)) * 2);
      }catch(java.io.IOException ex){
          return null;
      }
      byte b1 = raf.readByte();
      byte b2 = raf.readByte();
  
      byte[]bytes = new byte[] {b1,b2};
  
      BigInteger swap = new BigInteger(bytes);
  
      raf.close();
  </code></pre>