title: write hex string as bytes to socket java
body: <p>I have a string of hex values that I am trying to write to a socket as bytes.</p>
  
  <pre><code>String confDeliv = "\\x7E\\x01\\x00\\x20\\x37\\x02\\x03\\xF2\\xD5";
  </code></pre>
  
  <p>I have tried doing this to try and solve my problem</p>
  
  <pre><code>byte [] Delivery_Conf = {(byte)0x7E, (byte)0x01, (byte)0x00, (byte)0x20,
                               (byte)0x37, (byte)0x02, (byte)0x03, (byte)0xF2, (byte)0xD5};
  </code></pre>
  
  <p>But I have yet to succeed to write it to the socket. I don't get any errors but when I send it to the device it doesn't do what I need it to do I have tried two different ways of doing this.</p>
  
  <p>Try 1:</p>
  
  <pre><code>DataOutputStream dOut = new DataOutputStream(sock.getOutputStream());                                           //69.171.154.64
  
      for (int i = 0; i &lt; Delivery_Conf.length-1; i++) {
          dOut.writeByte(Delivery_Conf[i]);
      }
  dOut.flush();
  </code></pre>
  
  <p>This method I used when I but the values into a byte array.</p>
  
  <p>Try 2:</p>
  
  <pre><code>DataOutputStream dOut = new DataOutputStream(sock.getOutputStream());                                           
  
              dOut.writeBytes(confDeliv);
              dOut.flush();
  </code></pre>
  
  <p>This is the method I used when I tried sending it as the string but still no luck. I am able to make the device work when I use python using its byte string.</p>
  
  <p>eg.</p>
  
  <pre><code>confDel = b"\x7E\x01\x00\x20\x37\x02\x03\xF2\xD5"
  </code></pre>
  
  <p>I think java changes something when I send it and I think that is why I can get it to work with java. I have looked around for while but I do not seem to find anything that will help me with my problem.</p>