编写程序拷贝一个文件. 尽量使用效率高的方式。简单易懂的(适合初学者的)

解决方案 »

  1.   

    JAVA NIOFileChannel source = new FileInputStream(sourceFile).getChannel();;
    FileChannel destination = new FileOutputStream(destFile).getChannel();
    destination.transferFrom(source, 0, source.size());
      

  2.   

    java 7 : java.nio.file.Filesstatic long  copy(InputStream in, Path target, CopyOption... options)
    Copies all bytes from an input stream to a file.static long  copy(Path source, OutputStream out)
    Copies all bytes from a file to an output stream.static Path  copy(Path source, Path target, CopyOption... options)
    Copy a file to a target file.