gpt4 book ai didi

java - 有没有办法使用相同的 FileChannel 进行读写?

转载 作者:行者123 更新时间:2023-12-02 07:45:54 24 4
gpt4 key购买 nike

我是 Java NIO 新手。我发现 FileChannel 对象具有读取和写入方法。但我无法在单个时间点使用相同的 FileChannel 进行读写。有没有办法做到这一点?

最佳答案

从具有“rw”模式的 RandomAccessFile 对象获取一个 FileChannel

RandomAccessFile aFile     = new RandomAccessFile("abc.txt", "rw");
FileChannel inChannel = aFile.getChannel();

您可以引用此链接了解更多信息。 FileChannel tutorial

关于java - 有没有办法使用相同的 FileChannel 进行读写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10876583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com