| |
Read an Image from URL |
|
import java.awt.BorderLayout;
import java.awt.Image;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main {
public static void main(String[] argv) throws Exception {
URL url = new URL("http://yourServer.com/source.gif");
Image image = ImageIO.read(url);
JFrame frame = new JFrame();
JLabel label = new JLabel(new ImageIcon(image));
frame.getContentPane().add(label, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}
|
|
|
Related examples in the same category |
1. | Show Image with ImageReader | | | 2. | Add Image IO Read Progress Listener to ImageReader | | | 3. | Read an Image from a file | | | 4. | Read an Image from inputStream | | | 5. | Determining the Format of an Image in a File | | | 6. | Detect the file type of the input stream prior to reading the image | | | 7. | List the image formats that can be read and written | | | 8. | Get file format, image resolution, number of bits per pixel (JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM, PSD and SWF files) | | | 9. | Image format info | | | 10. | Image observer blocks until the image is completely loaded. AWT defers the loading of images until they are painted on a graphic. | | |
|