title: How do I convert a byte array with null terminating character to a String in Java?
body: <p>How can I create a String object from a byte array</p>
  
  <pre><code>byte arr[MAX_SIZE];  // Java
  </code></pre>
  
  <p>where one of the array elements is a C null terminating byte?  Is it as simple as calling</p>
  
  <pre><code>String str = new String( arr );
  </code></pre>
  
  <p>Will the String constructor know to automatically stop at the null terminating character?  Any bytes after the null byte are (possibly) garbage characters that I don't want to include in the string.  The last response under <a href="https://stackoverflow.com/questions/5106531/parsing-byte-array-in-java">Parsing byte array containg fields of unknown length</a> suggests looping through the array and manually finding the null terminating character, but I was wondering whether the String constructor will do this automatically. I also assume the system's default charset will be used on all ends.</p>