import java.io.BufferedInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; FileOutputStream fos = null; try{ //读取到本地硬盘中 fos = new FileOutputStream(new File("e://icon.zip")); fos.write(bt); fos.flush(); fos.close(); //读取mobile2.zip中的内容到images/background/mobile2 ZipFile zfile = new ZipFile("e://icon.zip"); Enumeration zList = zfile.entries(); byte[] buf = new byte[1024]; while (zList.hasMoreElements()) { ZipEntry ze = (ZipEntry) zList.nextElement(); if (ze.isDirectory()) { continue; } String icon_name = CharSet.toGB2312(ze.getName()); boolean isChinese = false; byte[] b = icon_name.getBytes(); for(int i=0;i<b.length;i++){ //判断图标名称是否含有中文,只要含有中文,就进行下一轮循环。b[i]=0时时中文,b[i]=63时是'?' if(b[i]<0 || b[i]==63){ isChinese = true; break; } } if(isChinese){ continue; } // 以ZipEntry为参数得到一个InputStream,并写到OutputStream中 OutputStream os = new BufferedOutputStream(new FileOutputStream(getServletContext().getRealPath("/")+"images//background//mobile2//"+icon_name)); InputStream is = new BufferedInputStream(zfile.getInputStream(ze)); int readLen = 0; while ((readLen = is.read(buf)) != -1) { os.write(buf, 0, readLen); } os.close(); is.close(); } zfile.close(); }catch(Exception e){ e.printStackTrace(); }