Here you can find the source of asInputStream(String str)
public static InputStream asInputStream(String str)
//package com.java2s; //License from project: LGPL import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; public class Main { private static final String CHARSET = "UTF-8"; public static InputStream asInputStream(String str) { try {//from w w w. jav a 2s . c o m return new ByteArrayInputStream(str.getBytes(CHARSET)); } catch (UnsupportedEncodingException e) { // doesn't know UTF8? Why is this even a checked exception? assert false; } return null; } }