title: Java convert hex string to java: char[] (C) to byte[] (JAVA)
body: <p>How to convert hex string in java that keep the same values.</p>
  
  <p>In C i have:</p>
  
  <pre><code>char tab[24] = { 0x02, 0x04, 0xF3, 0xFC, 0xFF, 0x06, 0x00, 0xF7, 0x00, 0x00, 0x09, 0xFD, 0xFD, 0x00, 0x03, 0x0A, 0xFD, 0x02, 0xFD, 0x08, 0x08, 0x00, 0x01, 0xFD };
  </code></pre>
  
  <p>And i copy to java like a string;</p>
  
  <pre><code>String hexString = "0x02, 0x04, 0xF3, 0xFC, 0xFF, 0x06, 0x00, 0xF7, 0x00, 0x00, 0x09, 0xFD, 0xFD, 0x00, 0x03, 0x0A, 0xFD, 0x02, 0xFD, 0x08, 0x08, 0x00, 0x01, 0xFD";
  </code></pre>
  
  <p>Now i want to convert in byte[], i find some ways how to do it but it looks like i do not convert in right format. </p>
  
  <p><strong>SOLVED</strong></p>
  
  <pre><code>String[] split = hexString.split(", ");       
  byte[] arr = new byte[split.length];
  for (int i = 0; i &lt; split.length; i++)
  {
      arr[i] = (byte)(short)Short.decode(split[i]);
  }
  </code></pre>