code: public static String read(InputStream in) throws IOException {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          byte[] buffer = new byte[1024];
          int length = 0;
          while ((length = in.read(buffer)) != -1) {
              baos.write(buffer, 0, length);
          }
          return new String(baos.toByteArray());
      }
docs: Read the entire input stream in 1KB chunks
  
  @param in input stream to read from
  @return a String generated from the input stream
  @throws IOException thrown by the input stream