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;
}
httpclient读取inputstream流
最新推荐文章于 2022-11-14 10:39:32 发布