Convering String to inputStream java

There are a number of places where string would be needed to be changed to InputStream object. For example the Dom parser would expect an InputStream for the creation of its DocumentBuilder

Here is the simple yet powerful single line doing the task!!

inputStream = new ByteArrayInputStream(string.getBytes("UTF-8"));