title: Store animated GIF image in a Java program
body: <p>In a Java program you can store images like .png, .jpg and such in a <code>BufferedImage</code>. I don't think it works for animated gif images as it seems to lose its animation.</p>
  
  <p>Currently I get normal images like:</p>
  
  <pre><code>BufferedImage image = ImageIO.read(new URL(images.get(x)));
  String type = images.get(x).substring(images.get(x).length() - 3, images.get(x).length());
  ImageIO.write(image, type, new File(title + "/" + filename));
  </code></pre>
  
  <p>Where <code>images</code> is a <code>String[]</code> of URLs.</p>
  
  <p>As for gif's I'm getting them by:</p>
  
  <pre><code>byte[] b = new byte[1];
  URL url = new URL(images.get(x));
  URLConnection urlConnection = url.openConnection();
  urlConnection.connect();
  DataInputStream di = new DataInputStream(urlConnection.getInputStream());
  
  FileOutputStream fo = new FileOutputStream(title + "/" + filename);
  while (-1 != di.read(b, 0, 1) &amp;&amp; downloading)           
      fo.write(b, 0, 1);
  di.close();
  fo.close();
  </code></pre>
  
  <p>But I want to store them in the program and write them to a file another time. How do I store a GIF without writing it to a file but while keeping its animation?</p>