code: public static String readInputStreamToString( InputStream inputStream ) {
  
          try {
              // Create the byte list to hold the data
              List<Byte> bytesList = new ArrayList<Byte>();
  
              byte b = 0;
              while( (b = (byte) inputStream.read()) != -1 ) {
                  bytesList.add(b);
              }
              // Close the input stream and return bytes
              inputStream.close();
  
              byte[] bArray = new byte[bytesList.size()];
              for( int i = 0; i < bArray.length; i++ ) {
                  bArray[i] = bytesList.get(i);
              }
  
              String file = new String(bArray);
              return file;
          } catch (IOException e) {
              e.printStackTrace();
              return null;
          }
      }
docs: Read from an inoutstream and convert the readed stuff to a String. Usefull for text files
  that are available as streams.
  
  @param inputStream
  @return the read string