public static InputStream toStream(String content, Charset charset) {
        byte[] bytes = content.getBytes(charset);
        return new ByteArrayInputStream(bytes);
    }
public static InputStream toStream ( String content , Charset charset ) { byte [ ] bytes = content . getBytes ( charset ) ; return new ByteArrayInputStream ( bytes ) ; }
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).