java - How comes .array() doesn't work on ByteBuffers returned from map'ed FileChannels? -


I'm in the memory mapped IO Java Failcanl class you map a Baitbfr to a specific part of a file Allows to I'm just opening a file to read.

The problem is that I am getting an exception when I try to call. As a result, the .ray () method on the bytebuger is probably the reason why .ray () returns a byte [] array, and I really want a last byte array?

Is there a way around this?

I'm going to assume this is about the method that can map a file to memory Is someone whom Can be used by

filechannel.map In the document for the document, if the file is mapped as read, any effort to modify buffer will only result:

One field of one file can be mapped to one of three ways:

  • Read-only: Any attempt to modify the resulting buffer The reason for throwing a ReadOnlyBufferException will be the reason. ( MapMode.READ_ONLY )

In terms of the exceptions thrown by law, except for the two types that are thrown by the

  • ReadOnlyBufferException - If this buffer is supported with an array, but only read

    Li>

  • < code> Unsupported exception - If this buffer is not mentioned in any intelligible array is not done

thrown though the exception question, S It is said that the file can be thrown only by read only by the array method. In addition, it should also be noted that the method is an optional operation:

returns the byte array that returns this buffer (optional operation).

To ensure that the array method is a byte [] which can be used, hasArray method as s: Recommended tips in documentation for the array method:

To apply this method before applying this method Make sure this buffer has an accessible backing array.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -