gpt4 book ai didi

JAVA - 不可写 channel 异常

转载 作者:行者123 更新时间:2023-12-02 03:14:00 25 4
gpt4 key购买 nike

public FileProcessor(String filenameIn, String fileModeIn){
try {
randomaccessfile = new RandomAccessFile(filenameIn, fileModeIn);
fileChannel = randomaccessfile.getChannel();
buffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, fileChannel.size());
} catch (FileNotFoundException e) {
System.err.println("Error while creating a File");
e.printStackTrace();
System.exit(1);
} catch (IOException e) {
System.err.println("Error while creating MappedByteBuffer");
e.printStackTrace();
System.exit(1);
}

获取

Exception in thread "main" java.nio.channels.NonWritableChannelException
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:880)

最佳答案

如果你想在映射你需要的文件时READ_WRITE"rw"创建 RandomAccessFile 时你最终会从..

关于JAVA - 不可写 channel 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40599842/

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