在程序中使用 ImageIO.read( )方法后,程序就停止不运行了,也没有报错。大神在哪儿!~~~求解决思路~~~代码如下:
File file = new File(filePath+File.separator+ fileName);
if(file.exists()){
ImageIO.read(file);//执行到此处,debug就停止了,不执行下一行
System.out.println(1);
}

解决方案 »

  1.   

    进入死循环了吧 因为这句一直为真if(file.exists())  你的read方法写错地方了 
      

  2.   

    try catch 用上 扑捉下异常 
      

  3.   


    在项目中已经用了try catch ,但没有报错,没抛出异常。
      

  4.   

    ImageIO加载的图片很多时候直接给ConvolveOp进行过滤的时候会出错,格式不对,必须手动的转换成BufferedImage才好用
      

  5.   


    求 手动转换成bufferedimage的方法
      

  6.   

        /**
         * Convert the image to an buffered image.
         * @param image An instance of the class Image
         * @return An instance of the class BufferedImage that is converted from an image.
         */
        public static BufferedImage imageToBufferedImage(Image image) {
            int width = image.getWidth(null);
            int height = image.getHeight(null);        BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            Graphics g = buf.createGraphics();
            g.drawImage(image, 0, 0, width, height, null);
            g.dispose();        return buf;
        }