Java 文件的Copy

/**
     * 复制文件
     * @param in
     * @param out
     * @throws Exception
     */
    private boolean copyFile(File in, File out) throws Exception{  
        FileChannel sourceChannel= new FileInputStream(in).getChannel();  
        FileChannel destinationChannel= new FileOutputStream(out).getChannel();  
        sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);  
        // or  
        // destinationChannel.transferFrom(sourceChannel, 0,  
        // sourceChannel.size());  
        sourceChannel.close();  
        destinationChannel.close();  
        sourceChannel= null;  
        destinationChannel= null;  
        return true;
    }  
原文地址:https://www.cnblogs.com/aloe/p/2606135.html