首页 > 编程语言 >java copyFile

java copyFile

时间:2022-12-02 17:57:29浏览次数:46  
标签:index java copyFile fos fis new

 

java copyFile

 

public static void copyFile(File oldFile,File newFile) throws IOException{
    FileInputStream fis = new FileInputStream(oldFile);
    FileOutputStream fos = new FileOutputStream(newFile);
    int index=0;
    byte[] bytes = new byte[1024];
    while((index=fis.read(bytes))!=-1) {
        fos.write(bytes, 0, index);
    }
    fos.flush();
    fos.close();
    fis.close();
}

 

 

 

 

##########################

标签:index,java,copyFile,fos,fis,new
From: https://www.cnblogs.com/herd/p/16260779.html

相关文章