| @@ -19,6 +19,7 @@ import java.io.ByteArrayOutputStream; | |||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import org.apache.poi.util.IOUtils; | import org.apache.poi.util.IOUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -37,15 +38,20 @@ public class FileLoadeImpl implements IFileLoader { | |||||
| private static final Logger LOGGER = LoggerFactory.getLogger(FileLoadeImpl.class); | private static final Logger LOGGER = LoggerFactory.getLogger(FileLoadeImpl.class); | ||||
| public byte[] getFile(String url) { | public byte[] getFile(String url) { | ||||
| FileInputStream fileis = null; | |||||
| InputStream fileis = null; | |||||
| ByteArrayOutputStream baos = null; | ByteArrayOutputStream baos = null; | ||||
| try { | try { | ||||
| //先用绝对路径查询,再查询相对路径 | //先用绝对路径查询,再查询相对路径 | ||||
| try { | try { | ||||
| fileis = new FileInputStream(url); | fileis = new FileInputStream(url); | ||||
| } catch (FileNotFoundException e) { | } catch (FileNotFoundException e) { | ||||
| String path = PoiPublicUtil.getWebRootPath(url); | |||||
| fileis = new FileInputStream(path); | |||||
| //获取项目文件 | |||||
| fileis = ClassLoader.getSystemResourceAsStream(url); | |||||
| if (fileis == null) { | |||||
| //最好再拿想对文件路径 | |||||
| String path = PoiPublicUtil.getWebRootPath(url); | |||||
| fileis = new FileInputStream(path); | |||||
| } | |||||
| } | } | ||||
| baos = new ByteArrayOutputStream(); | baos = new ByteArrayOutputStream(); | ||||
| byte[] buffer = new byte[1024]; | byte[] buffer = new byte[1024]; | ||||