Java如何将文件复制(写)到另一个文件当中

/**
 * @param targetFile 该文件是已被创建的文件
 */
private void copyFile(File targetFile){
    //生产的临时文件
    File file = exportService.exportByTmpl();
    InputStream ins = new FileInputStream(file);
    OutputStream outs = new File0utputStream(targetFile);
    int count;
    byte[] by = new byte[1024];
    while((count =ins.read(by))!=-1){
        outs.write(by, 0, count);
    }
}

 

posted @ 2024-12-17 11:00  TIME_小白  阅读(32)  评论(0)    收藏  举报