Monday, May 7, 2007

read and write image file (or other files) from one location to another

import javax.imageio.ImageIO;
import java.io.*;
import java.awt.image.*;

public class ReadImage
{
public static void main(String args[]) throws Exception
{
File f = new File("location1\\file1.jpg");
File f1 = new File("location2\\file2.jpg");

FileInputStream fis = new FileInputStream(f);
byte b[] = new byte[9999999];
int len = fis.read(b);

FileOutputStream fos = new FileOutputStream(f1);
fos.write(b,0,len);
}
}

No comments: