public static InputStream string2InputStream(String str) throws UnsupportedEncodingException ... { ByteArrayInputStream bais = new ByteArrayInputStream(str.getBytes()); return bais; } public static String inputStream2String(InputStream is) throws IOException ... { byte[] buffer = new byte[is.available()]; is.read(buffer); return new String(buffer); }