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);
}
异常线程 “main” java.nio.channels.NonWritableChannelException 在sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:880)JAVA - 非可写通道异常
获取NonwritableChannelException为上面的代码。请帮忙。谢谢。!!
什么是你的fileModeIn? – developer
我得到一个文件模式作为输入,但默认设置为READ_WRITE – ShreyasMN