想读取resouce/picture下的bottom.png文件。只有第二种方式才能正常工作!
方式一:
File sourceFile = ResourceUtils.getFile("classpath:picture/bottom.png"); //这种方法在linux下无法工作
方式二:
Resource resource = new ClassPathResource("picture/bottom.png");
// 有些系统提示找不到资源,可以把上面的代码换成下面这句:
// ClassPathResource resource = new ClassPathResource("picture/bottom.png");
File sourceFile = resource.getFile();