用ImageIO.read()可以读入JPG格式的图片。
好象不能读入GIF。

解决方案 »

  1.   

    Gif4J http://www.gif4j.com/index.htm
      

  2.   

    你的JDK是哪个版本?
    使用 ImageIO.getReaderFormatNames(),ImageIO.getWriterFormatNames() 
    看看
      

  3.   

    可以读取
    ImageIO.read(new File("/images/001.gif"));
      

  4.   

    BufferedImage image = ImageIO.read(new URL(url));
      

  5.   

    ImageIO.read(new File(filepath+filename));
      

  6.   

    读gif文件那是必须的
    记得以前自己好玩实现过一个用流直接读取。
      

  7.   

    通过ImageIO.read读出来返回是一个BufferedImage对象。
    而不是一个动画的GIF
      

  8.   

    import java.awt.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.BorderLayout;
    import javax.swing.JLabel;
    import javax.swing.ImageIcon;public class MainFrame extends JFrame {
        JPanel contentPane;
        JLabel imageLabel = new JLabel();
        JLabel headerLabel = new JLabel();    public MainFrame() {
            try {
                setDefaultCloseOperation(EXIT_ON_CLOSE);
                contentPane = (JPanel) getContentPane();
                contentPane.setLayout(new BorderLayout());
                setSize(new Dimension(400, 300));
                setTitle("Your Job Crashed!");
                // add the header label
                headerLabel.setFont(new java.awt.Font("Comic Sans MS", Font.BOLD, 16));
                headerLabel.setText("   Your job crashed during the save process!");
                contentPane.add(headerLabel, java.awt.BorderLayout.NORTH);
                // add the image label
                ImageIcon ii = new ImageIcon(this.getClass().getResource(
                        "snoopy_dancing.gif"));
                imageLabel.setIcon(ii);
                contentPane.add(imageLabel, java.awt.BorderLayout.CENTER);
                // show it
                this.setLocationRelativeTo(null);
                this.setVisible(true);
            } catch (Exception exception) {
                exception.printStackTrace();
            }
        }    public static void main(String[] args) {
            new MainFrame();
        }}
      

  9.   

    楼主可以看一下《Java 核心技术》下卷“读取和写入带有多个图像的文件”(第七版为 7.10.2 节,pp.446~454),里面有讲到如何读到 GIF 文件。
      

  10.   

    InputStream imageIn = context.getResourceAsStream(imagePath);// 文件流
    BufferedInputStream bis = new BufferedInputStream(imageIn);// 输入缓冲流
    BufferedOutputStream bos = new BufferedOutputStream(output);// 输出缓冲流