简体   繁体   English

由于权限问题,Java 7 ImageIO可能无法在Windows 7中读写

[英]Java 7 ImageIO can fail to read and write in Windows 7 due to permissions problems

I had a program running in Windows 7 64 bit using Java 6 which fails using Java 7. ImageIO it seems makes temporary cache files when reading and writing. 我有一个使用Java 6在Windows 7 64位上运行的程序,但使用Java 7却失败了。ImageIO似乎在读写时会生成临时缓存文件。 In my Eclipse IDE, ImageIO now hangs with no error messsage. 在我的Eclipse IDE中,ImageIO现在挂起,没有错误消息。 In another machine, I get an IOException permission denied. 在另一台计算机上,我获得了IOException权限被拒绝。

The workaround I've adopted is to read the image using Toolkit.createImage and convert to a BufferedImage. 我采用的解决方法是使用Toolkit.createImage读取图像并将其转换为BufferedImage。 This doesn't seem to need to create any files but is clunky. 这似乎不需要创建任何文件,但是很麻烦。 I am now writing by converting to a byte array. 我现在通过转换为字节数组来编写。

Is anyone else having these problems? 还有其他人有这些问题吗?

I had a performance problem with those cached files and solved it by calling javax.imageio.ImageIO.setUseCache(false) . 我对这些缓存的文件存在性能问题,并通过调用javax.imageio.ImageIO.setUseCache(false)解决了该问题。 As long as the original image files are already on a disk already, there shouldn't be a performance penalty. 只要原始映像文件已经在磁盘上,就不会有性能损失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM