title: Convert byte array to String - java
body: <p>I am trying to read in the content of a file to any readable form. I am using a FileInputStream to read from the file to a byte array, and then am trying to convert that byte array into a String. </p>
  
  <p>So far, I have tried 3 different ways:</p>
  
  <pre><code>FileInputStream inputStream = new FileInputStream(file);
  byte[] clearTextBytes = new byte[(int) file.length()];
  inputStream.read(clearTextBytes);
  
  String s = IOUtils.toString(inputStream); //first way
  
  String str = new String(clearTextBytes, "UTF-8"); //second way
  
  String string = Arrays.toString(clearTextBytes); //third way
  String[] byteValue = string.substring(1, string.length() - 1).split(",");
  byte[] bytes = new byte[byteValue.length]
  for(int i=0, len=bytes.length; i&lt;len; i++){
     bytes[i] = Byte.parseByte(byteValue[i].trim());
  }
  String newStr = new String(bytes);
  </code></pre>
  
  <p>When I print out each of the Strings:
  1) prints out nothing, and
  2 &amp; 3) print out a lot of weird characters, such as:
  PK!�Q���[Content_Types].xml �(���MO�@��&amp;��f��]�<code>��pP&lt;*���v
  �ݏ�,_��i�I�(zi�N��}fڝ�</code>��h�5)�&amp;��6Sf����c|�"�d��R�d���Eo�r��
  �l�������:0Tɭ�"Э�p'䧘��tn��&amp;�    q(=X����!.���,�_�WF�L8W......</p>
  
  <p>I would love any advice on how to properly convert my byte array to a String.</p>