The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.nio  [27 examples] > Files  [7 examples]

e168. Determining If a ByteBuffer Is Direct

A non-direct ByteBuffer is one where the contents are stored in the normal memory. A direct ByteBuffer is one where the contents are stored in some I/O device such as a disk drive or video board.

See also e158 Creating a ByteBuffer.

    ByteBuffer bbuf = ByteBuffer.wrap(new byte[10]);
    boolean isDirect = bbuf.isDirect();  // false
    
    bbuf = ByteBuffer.allocate(10);
    isDirect = bbuf.isDirect();          // false
    
    bbuf = ByteBuffer.allocateDirect(10);
    isDirect = bbuf.isDirect();          // true

 Related Examples
e166. Creating a Memory-Mapped File
e167. Persisting Changes to a Memory-Mapped ByteBuffer
e169. Reading from a Channel with a ByteBuffer
e170. Writing to a Channel with a ByteBuffer
e171. Writing and Appending a ByteBuffer to a File
e172. Copying One File to Another

See also: Byte Buffers    File Locking    Sockets    Streams   


© 2002 Addison-Wesley.