Package java.nio

Examples of java.nio.ByteBuffer.remaining()


                            ByteBuffer buf = bufs.remove(writePosition);
                            if (buf.remaining() > bytesToRemove) {
                                buf.position(buf.position() + bytesToRemove);
                                bufs.add(writePosition, buf);
                            } else {
                                bytesToRemove -= buf.remaining();
                            }
                           
                        // ...no
                        } else {
                            bytesToRemove = 0;
View Full Code Here


                    ByteBuffer[] data = bodyDataSource.readByteBufferByLength(bodyDataSource.available());
                   
                    if (currentSize < cache.getMaxSizeCacheEntry()) {
                        for (ByteBuffer buf : data) {
                            ByteBuffer bufCopy = buf.duplicate();
                            currentSize += bufCopy.remaining();
                            bodyCopy.add(bufCopy);
                        }
                    }
                   
                    bodyDataSink.write(data);
View Full Code Here

           
        } catch (Exception e) {
            buffer.position(position);
            buffer.limit(limit);
           
            if (buffer.remaining() > MAX_HEADER_SIZE) {
                throw new BadMessageException("max header size reached");
            } else {
                return null;
            }
        }
View Full Code Here

                } else {
                    buf = oldContent[i];
                }
               
                if (buf != null) {
                    size += buf.remaining();
                    getNonBlockingBody().append(buf);
                }
            }
        }
       
View Full Code Here

                }
               
                ByteBuffer buf = ByteBuffer.allocate(bufferSize);
                fc.read(buf);
                buf.flip();
                read += buf.remaining();

                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine(buf.remaining() + " bytes read from " + file.getAbsolutePath());
                }
               
View Full Code Here

                fc.read(buf);
                buf.flip();
                read += buf.remaining();

                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine(buf.remaining() + " bytes read from " + file.getAbsolutePath());
                }
               
                append(buf);
            }
        }
View Full Code Here

        do {
            ByteBuffer transferBuffer = ByteBuffer.allocate(chunkSize);
            read = source.read(transferBuffer);

            if (read > 0) {
                if (transferBuffer.remaining() == 0) {
                    transferBuffer.flip();
                    write(transferBuffer);

                } else {
                    transferBuffer.flip();
View Full Code Here

            ByteBuffer buffer = buffers[i];
            if (buffer == null) {
                continue;
            }
           
            int available = buffer.remaining();
               
            if (available == 0) {
                continue;
            }
           
View Full Code Here

  @Override
  void onDisconnectInHeader(AbstractHttpConnection httpConnection, ByteBuffer[] rawData) throws IOException {
        ByteBuffer buffer = HttpUtils.merge(HttpUtils.copy(rawData));

        int maxReadSize = 8;
        if (buffer.remaining() < maxReadSize) {
            maxReadSize = buffer.remaining();
        }
       
        // looking for slash of protocol -> HTTP/
        for (int i = 0; i < maxReadSize; i++) {
View Full Code Here

  void onDisconnectInHeader(AbstractHttpConnection httpConnection, ByteBuffer[] rawData) throws IOException {
        ByteBuffer buffer = HttpUtils.merge(HttpUtils.copy(rawData));

        int maxReadSize = 8;
        if (buffer.remaining() < maxReadSize) {
            maxReadSize = buffer.remaining();
        }
       
        // looking for slash of protocol -> HTTP/
        for (int i = 0; i < maxReadSize; i++) {
            if (buffer.get() == SLASH) {
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.