- import java.io.*;
- public class CopyFile {
- public static void main(String[] args) {
- try{
- FileInputStream input=new FileInputStream("f://downloads//kon.jpg");//可替换为任何路径何和文件名
- FileOutputStream output=new FileOutputStream("f://kon.jpg");//可替换为任何路径何和文件名
- int in=input.read();
- while(in!=-1){
- output.write(in);
- in=input.read();
- }
- }catch (IOException e){
- System.out.println(e.toString());
- }
- }
- }
怎样用Java复制一个文件到指定目录?
最新推荐文章于 2024-07-15 02:40:03 发布