Convert array of bytes to string then back it to array of bytes again
<p>I am a beginner in Java, I have array of bytes that I need to convert to string.<br>
After that I want to change it back from string to array of bytes.<br>
I tried the code below, but it did not work since the return value from line 2 does not match the original array:</p>

<pre><code>byte[] comData = byteArray;
String value = new String(comData);
byte[] comData2 = value.getBytes();
// comData2 does not equal comData 
</code></pre>
