title: Cast string array elements to byte array in java
body: <p>I have a string array of form:  </p>
  
  <pre><code>String[] s = {0x22, 0xD2, 0x01}
  </code></pre>
  
  <p>Now I have to convert it to byte array form like:  </p>
  
  <pre><code>byte[] bytes = {(byte)0x22, (byte)0xD2, (byte)0x01}
  </code></pre>
  
  <p>It can be done in single line in c# but how to do it in Java as I have to append <code>bytes</code> array to another array of same kind and format.  </p>
  
  <p>Here I have included some part of the code as I can't include whole code: </p>
  
  <pre><code>String sr = "22D201";
  String[] s = {sr.substring(0, 2),sr.substring(2, 4),sr.substring(4)};
  byte[] ret = new byte[]{(byte)0x2C, (byte)0x04, (byte)0x01, (byte)0x67, (byte)0x00, (byte)0x00, (byte)0x3D};
  </code></pre>
  
  <p>Now I have to append <code>byte[] bytes</code> to <code>byte[] ret</code> but I can't as array is in the form of String that is <code>String[] s</code>. So how to covert <code>String[] s</code> so that I can add it to <code>byte[] ret</code>.</p>