Example usage for java.nio MappedByteBuffer flip

List of usage examples for java.nio MappedByteBuffer flip

Introduction

In this page you can find the example usage for java.nio MappedByteBuffer flip.

Prototype

@Override
public final MappedByteBuffer flip() 

Source Link

Usage

From source file:MainClass.java

public static void main(String[] argv) throws Exception {
    RandomAccessFile raf = new RandomAccessFile("test.txt", "r");
    FileChannel fc = raf.getChannel();
    MappedByteBuffer buffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());

    buffer.clear();//from  w w  w  . j av  a  2 s  .c  o  m
    buffer.flip();

    System.out.println("hasArray=" + buffer.hasArray());
    System.out.println(buffer.toString());

    System.out.flush();
}