javax.imageio.IIOException: Can't create cache file!
at javax.imageio.ImageIO.createImageInputStream(ImageIO.java:361)
at javax.imageio.ImageIO.read(ImageIO.java:1351)
Caused by: java.nio.file.NoSuchFileException: D:\JAVASERVER\apache-tomcat-7.0.72-ElectBill-8091\temp\imageio3049143507735331701.tmp
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at java.nio.file.TempFileHelper.create(TempFileHelper.java:138)
at java.nio.file.TempFileHelper.createTempFile(TempFileHelper.java:161)
at java.nio.file.Files.createTempFile(Files.java:897)
由找不到文件引起:java.nio.file.NoSuchFileException: ...\temp\imageio3049143507735331701.tmp
主要原因是使用imgio包进行操作时,默认会使用缓存目录:${tomcat}/temp,在此缓存目录会生成缓存文件,
时间戳.tmp(这一串数字应该是当前时间戳,临时文件名),但是有些tomcat,会把temp目录进行删除,因此报错
解决方法:
1、tomcat的安装目录下新建一个temp目录。
2、ImageIO.setCacheDirectory(cacheDirectory),设置缓存目录。
3、ImageIO.setUseCache(false)设置,更改缓存策略,不使用文件目录缓存,使用内存缓存。
相关文章
- 11-22poetry install报错,提示“relative path can‘t be expressed as a file URI”
- 11-22SVN报错:can't open file db/txn-current-lock:permission denied 解决方法
- 11-22Fatal error, can‘t open config file ‘xxx‘: Permission denied
- 11-22Can't create handler inside thread Thread that has not called Looper.prepare()
- 11-22django migrate报错:1005 - Can't create table xxx (errno: 150 "Foreign key constraint is inc
- 11-22vi编辑文件出现Can't open file for writing错误
- 11-22Can't create handler inside thread that has not called Looper.prepare()
- 11-22成功解决ForkingPickler(file, protocol).dump(obj) TypeError: can't pickle Environment objects
- 11-22vi 新建文件出现E212: Can‘t open file for writing错误
- 11-22Gbase rmt远程导出时提示can’t create/write