try { // 检查是否是ZIP文件 ZipFile zip = new ZipFile(infile); zip.close();
// 建立与目标文件的输入连接 ZipInputStream in = new ZipInputStream(new FileInputStream(infile)); ZipEntry file = in.getNextEntry();
int i = infile.getAbsolutePath().lastIndexOf('.'); String dirname = new String(); if (i != -1) dirname = infile.getAbsolutePath().substring(0, i); else dirname = infile.getAbsolutePath();
File newdir = new File(dirname); newdir.mkdir();
byte[] c = new byte[1024]; int len; int slen;
while (file != null) { i = make8859toGB(file.getName()).replace('/', '\\').lastIndexOf('\\'); if (i != -1) { File dirs = new File(dirname + File.separator + make8859toGB(file.getName()).replace('/', '\\') .substring(0, i)); dirs.mkdirs(); dirs = null; }