|
@@ -39,8 +39,7 @@ public class FileDisposeUtil {
|
|
|
public static boolean saveUrlAs(String fileUrl, String fileName) {
|
|
|
try {
|
|
|
URL url = new URL(fileUrl);
|
|
|
- HttpURLConnection connection = (HttpURLConnection) url
|
|
|
- .openConnection();
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
DataInputStream in = new DataInputStream(connection.getInputStream());
|
|
|
DataOutputStream out = new DataOutputStream(new FileOutputStream(fileName));
|
|
|
byte[] buffer = new byte[4096];
|
|
@@ -135,7 +134,7 @@ public class FileDisposeUtil {
|
|
|
try {
|
|
|
File zipFile = new File(zipFilePath+File.separator+fileName+".zip");
|
|
|
if (zipFile.exists()) {
|
|
|
- logger.error(zipFilePath + "目录下存在名字为:" + fileName+ ".zip" + "打包文件.");
|
|
|
+ logger.error(zipFilePath + "目录下存在名字为:"+fileName+".zip"+"打包文件.");
|
|
|
} else {
|
|
|
File[] sourceFiles = sourceFile.listFiles();
|
|
|
if (null == sourceFiles || sourceFiles.length < 1) {
|
|
@@ -146,7 +145,9 @@ public class FileDisposeUtil {
|
|
|
byte[] bufs = new byte[1024 * 10];
|
|
|
for (int i = 0; i < sourceFiles.length; i++) {
|
|
|
// 创建ZIP实体,并添加进压缩包
|
|
|
- ZipEntry zipEntry = new ZipEntry(sourceFiles[i].getName());
|
|
|
+ String fileEncode = System.getProperty("file.encoding");
|
|
|
+ String name = new String(sourceFiles[i].getName().getBytes("utf-8"),fileEncode);
|
|
|
+ ZipEntry zipEntry = new ZipEntry(name);
|
|
|
zos.putNextEntry(zipEntry);
|
|
|
// 读取待压缩的文件并写进压缩包里
|
|
|
fis = new FileInputStream(sourceFiles[i]);
|