Here you can find the source of inputStream(final String in)
public static InputStream inputStream(final String in)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.IOException; import java.io.InputStream; public class Main { /**//w ww .ja v a 2s .c om * Makes an input stream from a String. * * BytesArrayInputStream is bugged. Use this instead. * */ public static InputStream inputStream(final String in) { return new InputStream() { int charindex = 0; public synchronized int read() throws IOException { if (charindex < in.length()) { return (int) in.charAt(charindex++); } else return -1; } }; } }