(String fileName)
| 16 | public class IOUtil { |
| 17 | |
| 18 | public static byte[] getBytesFromFile(String fileName) throws IOException { |
| 19 | URL url = IOUtil.class.getResource(fileName); |
| 20 | if (url == null) { |
| 21 | log.info("file:{}",fileName); |
| 22 | throw new FileNotFoundException(); |
| 23 | } |
| 24 | log.info("正在读取文件:{}",url.getFile()); |
| 25 | return getBytesFromStream(new FileInputStream(url.getFile())); |
| 26 | } |
| 27 | |
| 28 | public static byte[] getBytesFromStream(FileInputStream in) throws IOException { |
| 29 | FileChannel channel = in.getChannel(); |