public class TransferTo {
    public static void main(String[] args) throws Exception {
        FileChannel in = new FileInputStream("src/demo20/data.txt").getChannel(),
                out = new FileOutputStream("src/demo20/data2.txt").getChannel();
        in.transferTo(0, in.size(), out);
        
    }

}

通过nio来实现,transferTo方法即可实现.真的简单,不用写循环什么的,具体方法参考文档.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
猜你喜欢
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-09-13
  • 2022-12-23
  • 2021-12-11
相关资源
相似解决方案