import java.nio.*; import java.nio.LongBuffer; public class IsReadOnlyDemo { public static void main(String[] args) { LongBuffer longBuf = LongBuffer.allocate(256); if (longBuf.isReadOnly()) { System.out.println("Buffer is read only."); } else { System.out.println("Buffer is not read only."); } LongBuffer longBuf1 = longBuf.asReadOnlyBuffer(); if (longBuf1.isReadOnly()) { System.out.println("Buffer is read only."); } else { System.out.println("Buffer is not read only."); } } }