code: public static InputStream toStream(String content, Charset charset) {
          byte[] bytes = content.getBytes(charset);
          return new ByteArrayInputStream(bytes);
      }
docs: Converts the string of given content to an input stream.
  
  @param content the string content.
  @param charset the charset for conversion.
  @return the stream (should be closed by invoker).