Here you can find the source of toUTF8InputStream(String str)
public static InputStream toUTF8InputStream(String str)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; public class Main { /**//from w w w . ja v a 2s . c o m * Replacement for deprecated StringBufferInputStream(). Instead of: * InputStream is = new StringBuilderInputStream(str); * do: * InputStream is = StringUtil.toUTF8InputStream(str); */ public static InputStream toUTF8InputStream(String str) { InputStream is = null; try { is = new ByteArrayInputStream(str.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { // UTF-8 should always be supported throw new AssertionError(); } return is; } }