image reader and writer in java

by guruprasad 2014-04-28 10:47:51

Header files to be included:


import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;


Sample:

try{
BufferedImage image = null;
URL url = new URL("absolute path for the image file to be
read");
image = ImageIO.read(url);

//new path for the image to be stored with the new image name
ImageIO.write(image, "png", new File("file path"));
System.out.println("Imag success");
}
catch (IOException e) {
System.out.println("error:"+e);
}
809
like
0
dislike
0
mail
flag

You must LOGIN to add comments