IO流寫入寫出檔案複製
阿新 • • 發佈:2019-01-11
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();
}
}
}
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");
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();
}
}