private String inputStreamToString(InputStream is, String encoding) {
try {
byte[] b = new byte[1024];
String res = "";
if (is == null) {
return "";
}
int result = 0;
while (true) {
result = is.read(b, 0, 1024); // 返回读取的字节数
if (result == -1) {// 文件结束
return res;
}
res += new String(b, 0, result, encoding);
}
} catch (Exception e) {
e.printStackTrace();
System.out.print("Exception: " + e);
return "";
}
}