Java tutorial
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; public class Main { public static InputStream getStringStream(String sInputString) { ByteArrayInputStream tInputStringStream = null; if (sInputString != null && !sInputString.trim().equals("")) { byte[] bytes; try { bytes = sInputString.getBytes("UTF-8"); tInputStringStream = new ByteArrayInputStream(bytes); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return tInputStringStream; } }