Java ImageIO.read导致OSX挂起 [英] Java ImageIO.read causing OSX to hang

查看:139
本文介绍了Java ImageIO.read导致OSX挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Mac OSX上阅读图像时做一些事情,但是在调用ImageIO.read(File)时似乎挂起了。似乎没有出现堆栈跟踪,它实际上只是挂起。想知道是否有其他人遇到过这个问题?

I'm having to do some bits with reading in an image on Mac OSX, however it seems to hang when calling ImageIO.read ( File ). No stack trace seems to appear either, it literally just hangs. Was wondering if anyone else had experienced this problem?

我成功写了一个图像,看起来似乎是一个阅读问题。使用.png文件。

I've been successful in writing an image, just seems to be a problem with reading. Working with .png files.

OSX 10.9.2
Java 1.7.40

OSX 10.9.2 Java 1.7.40

推荐答案

我最终找到的解决方案是在mac上执行以下操作

The solution I found in the end was to do the following on the mac

File scrFile = ((TakesScreenshot)seleniumCommonHandler.getCurrentSeleniumDriver())
.getScreenshotAs(OutputType.FILE);

BufferedImage img = ImageIO.read( scrFile );

出于某种原因,无论我尝试什么,ImageIO都无法直接从文件系统中读取图像。通过使用这种方法,我设法解决了这个问题。

For some reason the ImageIO no matter what I tried could not read the image directly from the file system. By using this approach I managed to get around the issue.

这篇关于Java ImageIO.read导致OSX挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆