1. string to InputStreamString str = "String and InputStream convert each other"; InputStream in_nocode = new ByteArrayInputStream (str. getBytes (); InputStream in_withcode = new ByteArrayInputStream (str. getBytes ("UTF-8"); 2. inputStream to String: several methods are provided here. Method 1: public String convertStreamToString (InputStream is) {BufferedReader reader = new BufferedReader (new InputStreamReader (is); StringBuilder sb = new StringBuilder (); String line = null; try {while (line = reader. readLine ())! = Null) {sb. append (line + "/n") ;}} catch (IOException e) {e. printStackTrace ();} finally {try {is. close ();} catch (IOException e) {e. printStackTrace () ;}} return sb. toString ();} Method 2: public String inputStream2String (InputStream in) throws IOException {StringBuffer out = new StringBuffer (); byte [] B = new byte [4096]; for (int n; (n = in. read (B ))! =-1;) {out. append (new String (B, 0, n);} return out. toString ();} method 3: 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 ();}