零拷贝指的是对CPU零消耗或者尽量少消耗。

public static boolean copyFile(String sourcePath, String targetPath) {

        try (FileChannel source = new FileInputStream(sourcePath).getChannel();
             FileChannel target = new FileOutputStream(targetPath).getChannel()
        ) {
            long sourceSize = source.size();

            for (long left = sourceSize; left > 0; ) {
                left -= source.transferTo((sourceSize - left), left, target);
            }

        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }