public static String readStream(InputStream is) throws Exception{
String data=null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len= is.read())!=-1) {
baos.write(buffer, 0, len);
}
is.close();
//data = new String(baos.toString().getBytes("gbk"),"gbk");
data = baos.toString("gbk");//不写就是平台默认的码表
return data;
}
内存读写流
最新推荐文章于 2023-03-29 14:44:18 发布