//不帶編碼的,遇到中文亂碼就掛
public static String inputStream2String(InputStream is) throws Exception{ ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i=-1; while((i=is.read())!=-1){ baos.write(i); } return baos.toString(); } //帶編碼的 public static String inputStream2String (InputStream in , String encoding) throws Exception { StringBuffer out = new StringBuffer(); InputStreamReader inread = new InputStreamReader(in,encoding); char[] b = new char[4096]; for (int n; (n = inread.read(b)) != -1;) { out.append(new String(b, 0, n)); } return out.toString(); }