title: How to convert Java string to byte array?
body: <p>I'm new to Java and I'm sure this is very simple. I've been trying to convert a string to <code>byte[]</code> can't seem to do it. I'm using it for a printer. </p>
  
  <pre><code> ArrayList&lt;byte[]&gt; commands = new ArrayList&lt;byte[]&gt;();
   commands.add(new byte[] { 0x1b, 0x2d, 0x00 });
  </code></pre>
  
  <p>The above works fine but what i need is to be able to take the <code>0x1b</code>, <code>0x2d</code>, <code>0x00</code> value and insert it from a string like</p>
  
  <pre><code> String hexcode = "0x1b, 0x2d, 0x00";
   commands.add(new byte[] { hexcode });
  </code></pre>
  
  <p>I've tried a ton of stuff can't seem to get it to go.</p>