先放着 没时间改了

来源:互联网 发布:b2c模式的淘宝的特点 编辑:程序博客网 时间:2024/04/28 20:25
@RequestMapping(value = "/test/save")
  public @ResponseBody RetInfo saveApp(HttpServletRequest request) {
 logger.debug("testing~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
ZipFile file;
ZipEntry entry = null;
//InputStream in = new BufferedInputStream(new FileInputStream(file));
try {
file = new ZipFile("f:\\test.zip");
Enumeration enu = file.entries();
while(enu.hasMoreElements()){
entry = (ZipEntry) enu.nextElement();
if(!entry.isDirectory()){
if(entry.getName().equals("test/app.xml")){

InputStream xmlFile=file.getInputStream(entry);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
try {
Document doc = db.parse(xmlFile);
Element root = doc.getDocumentElement();
NodeList apps = root.getChildNodes();
if(apps != null){
for(int i=0;i<apps.getLength();i++){
Node app = apps.item(i);
if(app.getNodeType() == Node.ELEMENT_NODE){
Node info = app.getFirstChild();
System.out.println("appInfo1:"+info.getNodeValue());
System.out.println("appInfo2:"+info.getNodeName());
}
}
}

} catch (SAXException e) {
// TODO Auto-generated catch block
}
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
}
}



}
}
//ZipEntry entry = file.getEntry("app.xml");


} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
   
return null;
 
  }
0 0
原创粉丝点击