管道基础大数据平台系统开发-【后端】-Server
2
13693261870
2023-03-20 54283d6b0fdd3bc1b444e5a9556ca3a740125b5b
src/main/java/com/lf/server/helper/FileHelper.java
@@ -7,9 +7,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
@@ -423,4 +421,29 @@
            list.add(file);
        }
    }
    /**
     * 复制文件
     *
     * @param src  源文件
     * @param dest 目录文件
     */
    public static void copyFile(File src, File dest) throws IOException {
        InputStream is = null;
        OutputStream os = null;
        try {
            is = new FileInputStream(src);
            os = new FileOutputStream(dest);
            byte[] buffer = new byte[1024];
            int length;
            while ((length = is.read(buffer)) > 0) {
                os.write(buffer, 0, length);
            }
        } finally {
            os.close();
            is.close();
        }
    }
}