Examples of asReadOnlyBuffer()


Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

    public ByteBuffer getResourceAsBuffer(String resourceName) {
        final ByteBuffer data = resources.get(resourceName);
        if (data == null) {
            return null;
        } else {
            return (ByteBuffer) data.asReadOnlyBuffer().rewind();
        }
    }

    /**
     * Does this jar-file contain the resource with the given name.
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

   * Constructs a new read-only {@code java.nio.ByteBuffer} with the
   * same backing byte array.
   */
  public ByteBuffer asReadOnlyByteBuffer() {
    ByteBuffer byteBuffer = ByteBuffer.wrap(this.bytes);
    return byteBuffer.asReadOnlyBuffer();
  }

  /**
   * Constructs a new {@code String} by decoding the bytes using the
   * specified charset.
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

   * Constructs a new read-only {@code java.nio.ByteBuffer} with the
   * same backing byte array.
   */
  public ByteBuffer asReadOnlyByteBuffer() {
    final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
    return byteBuffer.asReadOnlyBuffer();
  }

  /*@
   * Constructs a new {@code String} by decoding the bytes using the
   * specified charset.
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

    int len = data.length();
    ByteBuffer bb = BufferUtils.createByteBuffer(len);
    for(int i=0 ; i<len ; i++) {
      bb.put(i, (byte)data.charAt(i));
    }
    return bb.asReadOnlyBuffer();
  }

  /**
   * @see #PLATFORM_WINDOWS
   * @see #PLATFORM_LINUX
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

                throw new IOException("Read past EOF");
            }
        } else {
            ByteBuffer buffer = file.getBuffer(currentBufferIndex);
            // we must duplicate (and make it read only while we are at it) since we need position and such to be independent
            currentBuffer = buffer.asReadOnlyBuffer();
            currentBuffer.position(0);
            bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex;
            // if we are at the tip, limit the current buffer to only whats available to read
            long buflen = length - bufferStart;
            if (buflen < BUFFER_SIZE) {
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

        content.limit(content.position() + capacity());
        ByteBuffer buffer = content.slice();
        buffer.position(position());
        buffer.limit(limit());
        content.limit(limit);
        return isReadonly() ? buffer.asReadOnlyBuffer() : buffer;
    }

    public Buffer duplicate() {
        ByteBufferBuffer buffer = new DelegateReleaseBuffer(getIndex(0, 0),
                capacity());
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

    public ByteBuffer asByteBuffer() {
        ByteBuffer buffer = ByteBuffer
                .wrap(content, getIndex(0, 0), capacity()).slice();
        buffer.position(position()).limit(limit());
        return isReadonly() ? buffer.asReadOnlyBuffer() : buffer;
    }

    public Buffer duplicate() {
        ByteArrayBuffer buffer = new DelegateReleaseBuffer(getIndex(0, 0),
                capacity());
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

        13,
        3,
        (byte) 0xbb };
    src.put(sa);
    src.flip();
    src = src.asReadOnlyBuffer();
 
    JBuffer peer = new JBuffer(Type.POINTER);
    peer.peer(src);
    assertEquals(8, peer.size());
    assertTrue(peer.isReadonly());
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

      final int read = channel.read(tmpBuffer);
      if (read != size) {
        throw new EOFException("Cannot read whole dictionary");
      }
      dictIS.close(); dictIS = null;
      buffer = tmpBuffer.asReadOnlyBuffer();
      success = true;
    } finally {
      if (success) {
        IOUtils.close(mapIS, posIS, dictIS);
      } else {
View Full Code Here

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()

   * Constructs a new read-only {@code java.nio.ByteBuffer} with the
   * same backing byte array.
   */
  public ByteBuffer asReadOnlyByteBuffer() {
    final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
    return byteBuffer.asReadOnlyBuffer();
  }

  /**
   * Constructs a new {@code String} by decoding the bytes using the
   * specified charset.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.