/**
* 读取流并拼接转换成字符串
*
* @param is
* 流
* @param encode
* 字符集编码 null的时候为gb2312
* @return 转换后的字符串
* @throws IOException
*/
public static String readInputStream(InputStream is, String encode)
throws IOException {
if (encode == null) {
encode = "gb2312";
}
BufferedReader in = null;
String res = "";
try{
in = new BufferedReader(new InputStreamReader(is, encode));
StringBuffer buffer = new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
buffer.append(line);
}
res = buffer.toString();
}catch(Exception e){
//异常处理
}finally{
is.close();
}
return res;
}