I have tried a lot but, all i can get is just the first image and not the animated gif.
The best solution at the moment was load an animated gif into icon, but i need the file. Here the code:
final URL url = new URL("http://www.freeallimages.com/wp-content/uploads/2014/09/animated-gif-images-2.gif");
JLabel l = new JLabel(new ImageIcon(url));
JOptionPane.showMessageDialog(null, l);
Can anyone help here?
This code just get the first image of gif (not animated):
public static void saveImage(String imageUrl, String destinationFile) throws IOException {
URL url = new URL(imageUrl);
InputStream is = url.openStream();
File file = new File(destinationFile);
file.getParentFile().mkdirs();
file.createNewFile();
OutputStream os = new FileOutputStream(destinationFile );
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
}
is.close();
os.close();
}