Package java.nio

Examples of java.nio.ByteBuffer.capacity()


                    bb.clear();
                    bb.putLong(index);
                    bb.putInt(size);
                    while (remaining > 0) {
                        int size2 = Math.min(remaining, bb.capacity());
                        bb.limit(size2);
                        excerpt.read(bb);
                        bb.flip();
                        remaining -= bb.remaining();
                        IOTools.writeAll(socket, bb);
View Full Code Here


                        excerpt.startExcerpt((int) size);
                        // perform a progressive copy of data.
                        long remaining = size;
                        bb.position(0);
                        while (remaining > 0) {
                            int size2 = (int) Math.min(bb.capacity(), remaining);
                            bb.limit(size2);
                            if (sc.read(bb) < 0)
                                throw new EOFException();
                            bb.flip();
                            remaining -= bb.remaining();
View Full Code Here

            // If the log is not being suppressed...
            if(logLevel != null && level >= logLevel.intValue()) {
                // Allocate a new buffer to hold the formatted log message
                ByteBuffer byteBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
                // Delegate to the native library to format the log message
                int size = LibC.INSTANCE.vsnprintf(byteBuffer, byteBuffer.capacity(), format, args);
                // If the message was formatted without error...
                if(size >= 0) {
                    // FIXME could reallocate a new buffer here and try again if size > capacity?
                    // Determine the number of available characters (actually number of bytes)
                    size = Math.min(size, BUFFER_SIZE);
View Full Code Here

      byteDimensions,
      new SampleOffset(1, 0),
      byteFormat
    );
   
    Assert.assertEquals(bytesWrapped.capacity(), byteBuffer.capacity());
    Assert.assertEquals(0, byteBuffer.compareTo(bytesWrapped));
 
 
  @Test
  public void testBandedLittleEndianSignedInteger16() {
View Full Code Here

      byteDimensions,
      new SampleOffset(1, 0),
      byteFormat
    );
   
    Assert.assertEquals(bytesWrapped.capacity(), byteBuffer.capacity());
    Assert.assertEquals(0, byteBuffer.compareTo(bytesWrapped));
  }
}
View Full Code Here

        // prim_file interface from R15 on
        ByteBuffer reply = ByteBuffer.allocate(1);
        reply.put(FILE_RESP_LFNAME);
       
        ByteBuffer data = ByteBuffer.allocate(2+files[i].length());
        data.limit(data.capacity());
        data.position(0);
                                data.putShort((short)files[i].length());
        IO.putstr(data, files[i], false);
       
        driver_output2(reply, data);
View Full Code Here

        // prim_file interface from R14 on
        ByteBuffer reply = ByteBuffer.allocate(1);
        reply.put(FILE_RESP_FNAME);
       
        ByteBuffer data = ByteBuffer.allocate(files[i].length());
        data.limit(data.capacity());
        data.position(0);
        IO.putstr(data, files[i], false);
       
        driver_output2(reply, data);
      }
View Full Code Here

      }
      else {
        // prim_file interface up to R13B
        ByteBuffer resbuf = ByteBuffer.allocate(files[i].length()+1);
        resbuf.put(FILE_RESP_OK);
        resbuf.limit(resbuf.capacity());
        resbuf.position(1);
       
        IO.putstr(resbuf, files[i], false);
       
        driver_output2(resbuf, null);
View Full Code Here

    public int putImageData(ByteBuffer buf) {
        buf.rewind();
        ByteBuffer chunk = ByteBuffer.allocate(buf.remaining());
        chunk.put(buf);
        data.add(chunk);
        return chunk.capacity();
    }

    public int getImageData(ByteBuffer buf) {
        buf.clear();
        if (iter == null) {
View Full Code Here

                ByteBuffer ciphertext1 = crypt.encryptCopy(plain);
                ByteBuffer ciphertext2 = crypt.encryptCopy(plain);
                ByteBuffer ciphertext3 = crypt.encryptCopy(plain);
                assertEquals(ciphertext1.capacity(), len);
                assertEquals(ciphertext2.capacity(), len);
                assertEquals(ciphertext3.capacity(), len);
                assertEquals(ciphertext1.remaining(), len);
                assertEquals(ciphertext2.remaining(), len);
                assertEquals(ciphertext3.remaining(), len);
               
                if(type.isStreamCipher) {
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.