public class StreamItools {
public static String getcontext(InputStream is){
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] buffer=new byte[1024];
int len=0;
while ((len=is.read(buffer))!=-1){
os.write(buffer,0,len);
}
return os.toString();
} catch (IOException e) {
e.printStackTrace();
}
return “”;
}
按行读取
最新推荐文章于 2021-06-24 20:28:11 发布