|
|
@@ -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"));
|
|
|
}
|
|
|
}
|