1. String --> InputStream
public static InputStream String2InputStream(String str) throws IOException{ ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); return stream;}
2. InputStream --> String
public static String inputStream2String(InputStream is) throws IOException{ ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i=-1; while((i=is.read())!=-1){ baos.write(i); } return baos.toString(); }