1. 程式人生 > >IO流寫入寫出檔案複製

IO流寫入寫出檔案複製

package a;
import java.io.*;;
public class a4 {
public static void main(String[] args) throws IOException {
File fi1=new File("C:/Users/Administrator/Desktop/a.png");
File fa2=new File("C:/Users/Administrator/Desktop/a1.jpg");
File fi=new File("C:/Users/Administrator/Desktop/avid.3gp");
File fa=new File("C:/Users/Administrator/Desktop/avid1.mp4");
try {
FileInputStream fis=new FileInputStream(fi1);
FileOutputStream fos=new FileOutputStream(fa2);
int i=0;
while((i=fis.read())!=-1){

fos.write(i);

}
fis.close();
fos.close();


} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}





}


}