code: public static String readString(final InputStream stream) throws IOException {
          InputStreamReader br = null;
          StringBuilder sb = new StringBuilder();
          try {
              br = new InputStreamReader(stream);
  
              int got;
              while (!Thread.currentThread().isInterrupted()) {
                  got = br.read();
                  if (got == -1) {
                      break;
                  }
  
                  sb.append((char) got);
              }
          } finally {
              if (br != null) {
                  try {
                      br.close();
                  } catch (final IOException ex) {
                  }
              }
  
          }
  
          return sb.toString();
      }
docs: Reads a string from the input stream.
  
  @param stream The stream.
  @return The string from that stream.
  @throws IOException If an I/O error occurs.