我在使用imageio读去图片的时候,首先读去了一张580kb的图片,成功读取,但是在读取一张781kb的图片时却提示Exception in thread "Thread-30" java.lang.OutOfMemoryError: Java heap space
,于是我追本溯源找到这段是这么写的:
/** Use the javax.imageio api to read the image. */
public ImageInformation readImage(String inFile){
try{
BufferedImage image = ImageIO.read(new File(inFile));
int tempWidth = image.getWidth();
int tempHeight = image.getHeight();
if ((tempWidth > 0) && (tempHeight > 0)){
myImage = image;
myWidth = tempWidth;
myHeight = tempHeight;
ImageInformation tempImageInformation = new ImageInformation(image, myImage.getWidth(), myImage.getHeight());
return tempImageInformation;
}
}
catch (Exception e){
}
return null;
}
错误应该就是在那句BufferedImage image = ImageIO.read(new File(inFile));但是我不知道怎么去修改,希望有哪位兄弟帮帮忙!
,于是我追本溯源找到这段是这么写的:
/** Use the javax.imageio api to read the image. */
public ImageInformation readImage(String inFile){
try{
BufferedImage image = ImageIO.read(new File(inFile));
int tempWidth = image.getWidth();
int tempHeight = image.getHeight();
if ((tempWidth > 0) && (tempHeight > 0)){
myImage = image;
myWidth = tempWidth;
myHeight = tempHeight;
ImageInformation tempImageInformation = new ImageInformation(image, myImage.getWidth(), myImage.getHeight());
return tempImageInformation;
}
}
catch (Exception e){
}
return null;
}
错误应该就是在那句BufferedImage image = ImageIO.read(new File(inFile));但是我不知道怎么去修改,希望有哪位兄弟帮帮忙!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货