|
@@ -12,6 +12,7 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
+import java.net.JarURLConnection;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLEncoder;
|
|
@@ -19,6 +20,7 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Enumeration;
|
|
|
+import java.util.jar.JarFile;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipFile;
|
|
|
import java.util.zip.ZipOutputStream;
|
|
@@ -28,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.util.ResourceUtils;
|
|
|
|
|
|
/**
|
|
|
* @author chenken
|
|
@@ -302,13 +305,14 @@ public class FileDisposeUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- public static void unZipFiles(String zipFileName, String targetDirName) throws IOException{
|
|
|
+
|
|
|
+ public static void unZipFiles(String zipFileName, String targetDirName) throws IOException {
|
|
|
if (!targetDirName.endsWith(File.separator)) {
|
|
|
targetDirName = targetDirName + File.separator;
|
|
|
}
|
|
|
ZipFile zipFile = null;
|
|
|
try {
|
|
|
- //Create the ZipFile object from the ZIP file
|
|
|
+ // Create the ZipFile object from the ZIP file
|
|
|
zipFile = new ZipFile(zipFileName);
|
|
|
ZipEntry entry = null;
|
|
|
String entryName = null;
|
|
@@ -326,12 +330,14 @@ public class FileDisposeUtil {
|
|
|
descFileDir = targetDirName + entryName;
|
|
|
if (entry.isDirectory()) {
|
|
|
// If entry is a directory, create the directory
|
|
|
-// entry.setUnixMode(755);// Solve Linux mess file Settings 644 directory Settings 755
|
|
|
+ // entry.setUnixMode(755);// Solve Linux mess file Settings
|
|
|
+ // 644 directory Settings 755
|
|
|
new File(descFileDir).mkdirs();
|
|
|
continue;
|
|
|
} else {
|
|
|
// If entry is a file, the parent directory is created
|
|
|
-// entry.setUnixMode(644);//Solve Linux mess file Settings 644 directory Settings 755
|
|
|
+ // entry.setUnixMode(644);//Solve Linux mess file Settings
|
|
|
+ // 644 directory Settings 755
|
|
|
new File(descFileDir).getParentFile().mkdirs();
|
|
|
}
|
|
|
File file = new File(descFileDir);
|
|
@@ -357,9 +363,10 @@ public class FileDisposeUtil {
|
|
|
zipFile.close();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static String getDocxBasePath() {
|
|
|
- return FileDisposeUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath()
|
|
|
- + "export_template/docx";
|
|
|
+ String path = FileDisposeUtil.class.getResource("/").getPath() + "templates/docx";
|
|
|
+ return path;
|
|
|
}
|
|
|
+
|
|
|
}
|