解析字符串:
封装一个解析字符串的工具类,方便调用
public static String readStream(InputStream is){
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len = 0;
byte[] buffer = new byte[1024];
while((len = is.read(buffer))!=-1){
baos.write(buffer,0,len);
}
is.close();
bos.close();
byte[] result = baos.toByteArray();
String temp = new String(result);
return temp;
}cath(IOException e){
e.printStackTrace();
return"获取失败";
}
}
时间: 2024-10-06 12:28:56