NIO_通道之间传输数据

通道之间传输数据

  transferFrom()

  transferTo()

@Test
    public void test3() throws IOException {
        FileChannel inChannel = FileChannel.open(Paths.get("1.png"), StandardOpenOption.READ);
        FileChannel outChannel = FileChannel.open(Paths.get("4.png"),StandardOpenOption.READ,StandardOpenOption.WRITE,StandardOpenOption.CREATE);
        
        inChannel.transferTo(0, inChannel.size(), outChannel);
        
        outChannel.close();
        inChannel.close();
    }

 

posted @ 2019-01-10 11:18  Tamako521  阅读(181)  评论(0编辑  收藏  举报