String to InputStream

Arguments in many methods in the Java APIs are of the type InputStream. This is how to get an InputStream from a String, where argument to getBytes, UTF-8, is the encoding to use:

InputStream is = new ByteArrayInputStream(myString.getBytes("UTF-8"));

[tags]Java[/tags]