Browse Source

Merge branch 'dev' into beta

sunyj 7 years ago
parent
commit
45ec0862a4

+ 7 - 2
crystal2jasper/src/main/java/com/uas/report/crystal2jasper/ResourceUtils.java

@@ -2,7 +2,9 @@ package com.uas.report.crystal2jasper;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.UnsupportedEncodingException;
 import java.net.URL;
+import java.net.URLDecoder;
 
 /**
  * @author sunyj
@@ -10,8 +12,11 @@ import java.net.URL;
  */
 public class ResourceUtils {
 
-    public static File getFile(String name) throws FileNotFoundException {
+    public static File getFile(String name) throws FileNotFoundException, UnsupportedEncodingException {
         URL resource = ResourceUtils.class.getClassLoader().getResource(name);
-        return resource == null ? null : new File(resource.getFile());
+        if (resource == null) {
+            throw new FileNotFoundException("文件不存在");
+        }
+        return new File(URLDecoder.decode(resource.getFile(), "UTF-8"));
     }
 }