src/org/nutz/lang/Files.java
public static boolean copyFile(File src, File target, long count) throws IOException {
        if (src == null || target == null || !src.exists())
            return false;
        if (!target.exists())
            if (!createNewFile(target))
                return false;

        // 0 字节？ 那就啥都不做咯
        if (count == 0)
            return true;

        FileInputStream ins = null;
        FileOutputStream ops = null;
        FileChannel in = null;
        FileChannel out = null;

        try {
            ins = new FileInputStream(src);
            ops = new FileOutputStream(target);
            in = ins.getChannel();
            out = ops.getChannel();

            long maxCount = in.size();
            if (count < 0 || count > maxCount)
                count = maxCount;

            in.transferTo(0, count, out);
        }
        finally {
            Streams.safeClose(out);
            Streams.safeFlush(ops);
            Streams.safeClose(ops);
            Streams.safeClose(in);
            Streams.safeClose(ins);
        }
        return target.setLastModified(src.lastModified());
    }
public static boolean copyFile(File src, File target, long count) throws IOException {
        if (src == null || target == null || !src.exists())
            return false;
        if (!target.exists())
            if (!createNewFile(target))
                return false;

        // 0 字节？ 那就啥都不做咯
        if (count == 0)
            return true;

        FileInputStream ins = null;
        FileOutputStream ops = null;
        FileChannel in = null;
        FileChannel out = null;

        try {
            ins = new FileInputStream(src);
            ops = new FileOutputStream(target);
            in = ins.getChannel();
            out = ops.getChannel();

            long maxCount = in.size();
            if (count < 0 || count > maxCount)
                count = maxCount;

            in.transferTo(0, count, out);
        }
        finally {
            Streams.safeClose(out);
            Streams.safeFlush(ops);
            Streams.safeClose(ops);
            Streams.safeClose(in);
            Streams.safeClose(ins);
        }
        return target.setLastModified(src.lastModified());
    }
将一个文件 copy 一部分（或者全部）到另外一个文件。如果目标文件不存在，创建它先。

@param src
源文件
@param target
目标文件
@param count
要 copy 的字节数，0 表示什么都不 copy， -1 表示 copy 全部数据
@return 是否成功
@throws IOException