long count = srcChannel.size(); while (count > 0) { count -= dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
long copied = 0; long totalSize = srcChannel.size(); while (copied < totalSize) { long toCopy = Math.min(1024*1024*1024, totalSize - copied); copied += dstChannel.transferFrom(srcChannel, copied, toCopy);
    public static void copyFile(File src, File dst, boolean safe) throws SVNException {        if (src == null || dst == null) {            return;        }        if (src.equals(dst)) {            return;        }        if (!src.exists()) {            dst.delete();            return;        }        File tmpDst = dst;        if (dst.exists()) {            if (safe) {                tmpDst = createUniqueFile(dst.getParentFile(), dst.getName(), ".tmp");            } else {                dst.delete();            }        }        FileChannel srcChannel = null;        FileChannel dstChannel = null;        FileInputStream is = null;        FileOutputStream os = null;        dst.getParentFile().mkdirs();        try {            is = new FileInputStream(src);            srcChannel = is.getChannel();            os = new FileOutputStream(tmpDst);            dstChannel = os.getChannel();            long count = srcChannel.size();            while (count > 0) {                count -= dstChannel.transferFrom(srcChannel, 0, srcChannel.size());            }        } catch (IOException e) {            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Cannot copy file ''{0}'' to ''{1}''", new Object[] {src, dst});            SVNErrorManager.error(err);        } finally {            if (srcChannel != null) {                try {                    srcChannel.close();                } catch (IOException e) {                    //                }            }            if (dstChannel != null) {                try {                    dstChannel.close();                } catch (IOException e) {                    //                }            }            SVNFileUtil.closeFile(is);            SVNFileUtil.closeFile(os);        }        if (safe && tmpDst != dst) {            rename(tmpDst, dst);        }        dst.setLastModified(src.lastModified());    }