Here you can find the source of toInputStream(String input, Charset cs)
public static InputStream toInputStream(String input, Charset cs)
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.Charset; public class Main { public static InputStream toInputStream(String input) { return toInputStream(input, Charset.defaultCharset()); }/* w w w .j a v a2s . c o m*/ public static InputStream toInputStream(String input, Charset cs) { return new ByteArrayInputStream(input.getBytes(cs)); } }