httpclient读取inputstream流

	public static String getString(InputStream is, String charset) {
		String str = null;
		if (is == null) {
			return str;
		}
		StringBuffer sb = new StringBuffer();
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(is,
					charset));
            char buffer[] = new char[4096];
            int len;
            while((len = br.read(buffer)) > 0) 
            	sb.append(new String(buffer, 0, len));
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		str = sb.toString();
		return str;
	}

你可能感兴趣的:(Inputstream)