code: public static byte[] getContent(InputStream in) throws IOException {
      try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        copy(in, baos);
        return baos.toByteArray();
      }
      finally {
        in.close();
      }
    }
docs: Returns the content of the specified input stream. The stream will be closed after calling this method.
  @param in the input stream to read
  @return the content of the input stream
  @throws java.io.IOException if an I/O error occurs