title: How to convert byte array to string and vice versa?
body: <p>I have to convert a byte array to string in Android, but my byte array contains negative values.</p>
  
  <p>If I convert that string again to byte array, values I am getting are different from original byte array values.</p>
  
  <p>What can I do to get proper conversion? Code I am using to do the conversion is as follows:</p>
  
  <pre><code>// Code to convert byte arr to str:
  byte[] by_original = {0,1,-2,3,-4,-5,6};
  String str1 = new String(by_original);
  System.out.println("str1 &gt;&gt; "+str1);
  
  // Code to convert str to byte arr:
  byte[] by_new = str1.getBytes();
  for(int i=0;i&lt;by_new.length;i++) 
  System.out.println("by1["+i+"] &gt;&gt; "+str1);
  </code></pre>
  
  <p>I am stuck in this problem.</p>