title: Why are the lengths different when converting a byte array to a String and then back to a byte array?
body: <p>I have the following Java code:</p>
  
  <pre><code>byte[] signatureBytes = getSignature();
  
  String signatureString = new String(signatureBytes, "UTF8");
  byte[] signatureStringBytes = signatureString.getBytes("UTF8");
  
  System.out.println(signatureBytes.length == signatureStringBytes.length); // prints false
  </code></pre>
  
  <p><strong>Q:</strong> I'm probably misunderstanding this, but I thought that <code>new String(byte[] bytes, String charset)</code> and <code>String.getBytes(charset)</code> are inverse operations?</p>
  
  <p><strong>Q:</strong> As a follow up, what is a safe way to transport a byte[] array as a String?</p>