private static final int BUFF_SIZE = 1024 * 4;
public static ReqResBean getReqResArchive(File zipFile)
throws FileNotFoundException, IOException, XMLException {
ReqResBean encpBean = new ReqResBean();
// BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(zipFile);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;
try{
boolean isReqRead = false;
boolean isResRead = false;
while ((entry = zis.getNextEntry()) != null) {
int count;
byte data[] = new byte[BUFF_SIZE];
File tmpFile = File.createTempFile(entry.getName(), "");
try{
FileOutputStream fos = new FileOutputStream(tmpFile);
BufferedOutputStream dest = new BufferedOutputStream(fos, BUFF_SIZE);
while ((count = zis.read(data, 0, BUFF_SIZE)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
if (entry.getName().equals("request.rcq")) {
Request reqBean = XMLUtil.getRequestFromXMLFile(tmpFile);
encpBean.setRequestBean(reqBean);
isReqRead = true;
}
else if(entry.getName().equals("response.rcs")){
Response resBean = XMLUtil.getResponseFromXMLFile(tmpFile);
encpBean.setResponseBean(resBean);
isResRead = true;
}
}
finally{
tmpFile.delete();