javax.imageio.IIOException: Can't read input file!

做项目用到Thumbnails,给图片添加水印遇到了这个问题,记录一下!

//源代码
public class ImageUtil { public static void main(String[] args) throws IOException { String basePath = Thread.currentThread().getContextClassLoader().getResource("").getPath(); System.out.println(basePath); Thumbnails.of(new File("G:\\不限速的百度云\\ssm校园商铺\\xiaohuangren.jpg")).size(200, 200) .watermark(Positions.BOTTOM_RIGHT, ImageIO.read(new File(basePath + "/shuiyin.jpg")), 0.25f) .outputQuality(0.8f).toFile("G:\\不限速的百度云\\ssm校园商铺\\xiaohuangrennew2.jpg"); } }
//异常信息
Exception in thread "main" javax.imageio.IIOException: Can't read input file!

 首先我的工程名用的中文,把路径打出来是这样的

/D:/Users/acer/%e9%a1%b9%e7%9b%ae%e5%ae%9e%e6%88%98/o2o/target/classes/

后面把工程名修改为英文之后,就没有这个异常啦!!!切忌,最好不要用中文命令项目以及工程名字!!!!

猜你喜欢

转载自www.cnblogs.com/yycy/p/11871954.html
今日推荐