INNER CODE UNIT · Java

copyFileUsingNio

Tencent/VasDolly · command/src/main/java/com/tencent/vasdolly/command/Util.java:395

    public static void copyFileUsingNio(File source, File dest) throws IOException {
        FileChannel in = null;
        FileChannel out = null;
        FileInputStream inStream = null;
        FileOutputStream outStream = null;
        File parent = dest.getParentFile();
        if (parent != null && (!parent.exists())) {
            parent.mkdirs();
        }
        if (source.getAbsolutePath().equals(dest.getAbsolutePath())) {
            System.out.println("No copying induces same absolute path, dest: " + dest.getAbsolutePath());
            return;
        }
        try {
            inStream = new FileInputStream(source);
            outStream = new FileOutputStream(dest, false);
            in = inStream.getChannel();
            out = outStream.getChannel();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…