1。
String path=request.getParameter("pic");
String inputpath="D://pic//b.jpg";
try {
FileChannel srcChannel = new FileInputStream(path).getChannel();
FileChannel dstChannel = new FileOutputStream(inputpath).getChannel();
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
srcChannel.close();
dstChannel.close();
} catch (IOException e) {
}
2。
import java.io.*;
public class copypicture {
public static void main(String[] args){
try{FileInputStream fin=new FileInputStream("C://img.jpg");
FileOutputStream fout=new FileOutputStream("C://img1.jpg");
byte[] buf=new byte[fin.available()];
fin.read(buf);
fout.write(buf);
fin.close();
fout.close();
System.out.println("file copy success!");
}catch(IOException e){System.out.println("copy file failed!");}
}
}