javax.imageio.IIOException: Can't create output stream解决方法
来源:互联网 发布:网络推广月度工作计划 编辑:程序博客网 时间:2024/05/22 08:05
在使用ImageIO.write时,发现在linux平台上,会出现异常:
javax.imageio.IIOException: Can't create output stream
查看日志,发现是由找不到文件引起
java.nio.file.NoSuchFileException: xxx.../temp/imageio4138671232726624650.tmp
主要原因如下:
在使用ImageIO进行图片写操作时,默认会使用缓存目录:${tomcat}/temp,在此缓存目录会生成缓存文件imageio4138671232726624650.tmp(这一串数字应该是当前时间戳,临时文件名),有些生产环境的tomcat,会将temp目录删除,因此报错
4种解决方法如下:
1、在tomcat下新建temp目录;
2、与方法1相似,通过ImageIO.setCacheDirectory(cacheDirectory);设置任意的、存在的缓存目录
3、ImageIO默认是使用缓存目录,可以通过ImageIO.setUseCache(false)来设置,更改缓存策略,不使用文件目录缓存,使用内存缓存
4、不使用ImageIO,换成其它JDK方法
ImageIO.write(bi, "jpg", baos);换成:
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
encoder.encode(image);
0 0
- javax.imageio.IIOException: Can't create output stream解决方法
- javax.imageio.IIOException: Can't create output stream解决方法
- javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Can't create output stream!
- javax异常: javax.imageio.IIOException: Can't create output stream解决方法
- JSP彩色验证码,javax.imageio.IIOException: Can't create output stream! 解决方法
- 使用javax.imageio.ImageIO生成验证码时报错javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Can't create output stream! (生成验证码Servlet)
- javax.imageio.IIOException: Can't create output stream! (生成验证码Servlet)
- javax.imageio.IIOException: Can't create output stream!tomcat 验证码,图片(原理)
- 解决tomcat报错javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Can't create output stream!tomcat 验证码,图片(原理)
- 读取验证码时 Caused by: javax.imageio.IIOException: Can't create cache file!
- 解决:Tomcat不能加载图片问题.javax.imageio.IIOException: Can't create cache file!
- 读取验证码时报错 Caused by: javax.imageio.IIOException: Can't create cache file!
- javax.imageio.IIOException: Can't read input file!
- 框架
- java中静态代码块的用法 static用法详解
- 数据库日期毫秒转换
- as3 组件通信
- Python 语言及其应用 Chapter_5_Note_4 Counter()计数器
- javax.imageio.IIOException: Can't create output stream解决方法
- ${pageContext.request.contextPath}的作用
- document.getelementbyid('id') 和 $('#id')的区别
- Struts1与Struts2的12点区别
- MySQL页以及每秒读写量评估的疑问
- 对系统需求分析的一点看法
- Android四大组件之ContentProvider(上)
- 【RT-Thread学习笔记 4】线程让出实验
- xUtils3.0版本的发送同步网络请求的方式