// 指定要读取文件的缓冲输入字节流
BufferedInputStream bis = new BufferedInputStream(myPost.getResponseBodyAsStream());
byte[] bytes = new byte[1024];// 用来存储每次读取到的字节数组
// 指定要写入文件的缓冲输出字节流
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int count = 0;
//从文件中按字节读取内容,到文件尾部时read方法将返回-1
while(( count = bis.read( bytes))!= -1){
bos.write( bytes, 0, count);// 写入到输出流
}
byte[] strByte = bos.toByteArray();
responseString = new String(strByte,0,strByte .length ,"utf-8" );
System. out.print( responseString);
bos.close();//关闭流
bis.close();
BeanXmlMappingUtils.toBeanUTF8(responseString,packet);// 将报文信息赋值回指定Bean
1、把读入的返回报文信息输入字节流
2、把写入的返回报文信息输出字节流
3、一直读到文件尾部
4、关闭流
5、将报文信息赋值给指定实体类