Browse Source

update

master
Fangjie Hu 8 years ago
parent
commit
3ace747624
  1. 59
      designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java

59
designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java

@ -200,7 +200,7 @@ public class DownLoadDependenceUI implements ActionListener {
}
//安装文件
unZipFiles(temp, FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir());
IOUtils.unZipFilesGBK(temp, FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir());
} else {
result = false;
@ -272,61 +272,4 @@ public class DownLoadDependenceUI implements ActionListener {
private String showFileLength() {
return totalSize == -1 ? "NAN" : totalSize / Math.pow(10, 6) + "";
}
@SuppressWarnings("unchecked")
public static boolean unZipFiles(String zipFileName, String extPlace) throws Exception {
System.setProperty("sun.zip.encoding", System.getProperty("sun.jnu.encoding"));
try {
(new File(extPlace)).mkdirs();
File f = new File(zipFileName);
ZipFile zipFile = new ZipFile(zipFileName,"GBK"); //处理中文文件名乱码的问题
if((!f.exists()) && (f.length() <= 0)) {
throw new Exception("no zip file!");
}
String strPath, gbkPath, strtemp;
File tempFile = new File(extPlace);
strPath = tempFile.getAbsolutePath();
Enumeration<?> e = zipFile.getEntries();
while(e.hasMoreElements()){
ZipEntry zipEnt = (ZipEntry) e.nextElement();
gbkPath=zipEnt.getName();
if(zipEnt.isDirectory()){
strtemp = strPath + File.separator + gbkPath;
File dir = new File(strtemp);
dir.mkdirs();
continue;
} else {
//读写文件
InputStream is = zipFile.getInputStream(zipEnt);
BufferedInputStream bis = new BufferedInputStream(is);
gbkPath=zipEnt.getName();
strtemp = strPath + File.separator + gbkPath;
//建目录
String strsubdir = gbkPath;
for(int i = 0; i < strsubdir.length(); i++) {
if(strsubdir.substring(i, i + 1).equalsIgnoreCase("/")) {
String temp = strPath + File.separator + strsubdir.substring(0, i);
File subdir = new File(temp);
if(!subdir.exists())
subdir.mkdir();
}
}
FileOutputStream fos = new FileOutputStream(strtemp);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int c;
while((c = bis.read()) != -1) {
bos.write((byte) c);
}
bos.close();
fos.close();
}
}
return true;
} catch(Exception e) {
FRContext.getLogger().info(e.getMessage());
return false;
}
}
}

Loading…
Cancel
Save