Package java.nio

Examples of java.nio.ByteBuffer.capacity()


      }
    } else {
      int checksumLen = ((len + bytesPerChecksum - 1)/bytesPerChecksum)*
                                                            checksumSize;

      if ( checksumBuf.capacity() != checksumLen) {
        throw new IOException("Length of checksums in packet " +
            checksumBuf.capacity() + " does not match calculated checksum " +
            "length " + checksumLen);
      }

View Full Code Here


      int checksumLen = ((len + bytesPerChecksum - 1)/bytesPerChecksum)*
                                                            checksumSize;

      if ( checksumBuf.capacity() != checksumLen) {
        throw new IOException("Length of checksums in packet " +
            checksumBuf.capacity() + " does not match calculated checksum " +
            "length " + checksumLen);
      }

      if (shouldVerifyChecksum()) {
        try {
View Full Code Here

    ByteBuffer small = ByteBuffer.wrap(DFSTestUtil.loadFile(filenameSmall));
    ByteBuffer large = ByteBuffer.wrap(DFSTestUtil.loadFile(filenameLarge));

    // now correct if it's otherwise
    if (small.capacity() > large.capacity()) {
      ByteBuffer tmpByteBuffer = small;
      small = large;
      large = tmpByteBuffer;
      String tmpFilename = filenameSmall;
      filenameSmall = filenameLarge;
View Full Code Here

    wrapped.put(raw);
    for (byte b = 0; b < 5; b++) {
      wrapped.put(b);
    }
    wrapped.position(5);
    wrapped.limit(wrapped.capacity() - 5);
    assertEquals(value, m.fromBytes(wrapped));
  }

  private <T> void checkTruncated(Marshaller<T> m, T value) {
    ByteBuffer buf = m.toBytes(value);
View Full Code Here

            BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
            boa.writeInt(-1, "len");
            conReq.serialize(boa, "connect");
            baos.close();
            ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
            bb.putInt(bb.capacity() - 4);
            bb.rewind();
            synchronized (outgoingQueue) {
                // We add backwards since we are pushing into the front
                if (!disableAutoWatchReset) {
                    SetWatches sw = new SetWatches(lastZxid,
View Full Code Here

                    // Flip the compressed payload ready for writing
                    compressedPayload.flip();

                    boolean fin = uncompressedPart.isFin();
                    boolean full = compressedPayload.limit() == compressedPayload.capacity();
                    boolean needsInput = deflater.needsInput();

                    if (fin && !full && needsInput) {
                        // End of compressed message. Drop EOM bytes and output.
                        compressedPayload.limit(compressedPayload.limit() - EOM_BYTES.length);
View Full Code Here

                            e);
                    continue;
                }

                try {
                    byte[] msgBytes = new byte[b.capacity()
                            + (Integer.SIZE / 8)];
                    ByteBuffer msgBuffer = ByteBuffer.wrap(msgBytes);
                    msgBuffer.putInt(b.capacity());

                    msgBuffer.put(b.array(), 0, b.capacity());
View Full Code Here

            BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
            boa.writeInt(-1, "len");
            conReq.serialize(boa, "connect");
            baos.close();
            ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
            bb.putInt(bb.capacity() - 4);
            bb.rewind();
            synchronized (outgoingQueue) {
                // We add backwards since we are pushing into the front
                if (!disableAutoWatchReset) {
                    SetWatches sw = new SetWatches(lastZxid,
View Full Code Here

         filePos += fe.size;

         // check if the entry is used or free
         if (fe.keyLen > 0) {
            // load the key from file
            if (buf.capacity() < fe.keyLen)
               buf = ByteBuffer.allocate(fe.keyLen);

            buf.clear().limit(fe.keyLen);
            file.read(buf, fe.offset + KEY_POS);
View Full Code Here

        } else {
            file = rootDir.addFile(fileName).getFile();
            file.write(0, data);
            file.flush();

            assertSize("bad file.length after write", data.capacity(), file.getLength());
        }

        remountFS(config, config.isReadOnly());

        if (!config.isReadOnly()) {
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.