将字符串转换为InputStream
import java.io.ByteArrayInputStream; /* 来 自* 时代Java - N o w J a v a . c o m */ import java.io.InputStream; public class Main { public static void main(String args[]){ String str1 = "this is a test"; byte[] bytes = str1.getBytes(); InputStream inputStream = new ByteArrayInputStream(bytes); } }