title: Java: How to reverse this byte[] to hex method?
body: <p>I found this online and it works for what I need it for but how do I reverse it, meaning how to I convert the hex string back into a byte[]?</p>
  
  <pre><code>private static final char[] HEX_CHARS = {
      '0', '1', '2' ,'3', '4', '5', '6', '7', '8', '9',
      'a', 'b', 'c', 'd', 'e', 'f'
  };
  
  public String toHexString(byte[] bytes)
  {
      StringBuilder sb = new StringBuilder();
      for(int i = 0; i &lt; bytes.length; i++) {
          byte b = bytes[i];
          sb.append(new char[] {HEX_CHARS[(b &gt;&gt; 4) &amp; 0x0f], HEX_CHARS[b &amp; 0x0f]});
      }
  
      return sb.toString();
  }
  </code></pre>