Package java.nio

Examples of java.nio.ByteBuffer.limit()


        {
            lOut = new ByteBufferOutputStream();
            lOut.write( IOUtil.encodeToBytes( toHeaderString(), CHARSET ) );
            ByteBuffer buffer = this._out.getBackingBuffer();
            int pos = buffer.position();
            int limit = buffer.limit();
            buffer.flip();
            lOut.write( buffer );
            result = lOut.getBackingBuffer();
            result.flip();
            buffer.limit( limit );
View Full Code Here


            int limit = buffer.limit();
            buffer.flip();
            lOut.write( buffer );
            result = lOut.getBackingBuffer();
            result.flip();
            buffer.limit( limit );
            buffer.position( pos );
        }
        catch ( IOException e )
        {
            //
View Full Code Here

     * @return an array of bytes containing all transportable settings in the connection header
     */
    public byte[] toBytes()
    {
        ByteBuffer buf = toByteBuffer();
        byte[] result = new byte[buf.limit()];
        buf.get( result );

        return result;
    }

View Full Code Here

        long timestamp = System.currentTimeMillis();
        long timePeriod = -1;
        do
        {
            limit = headerBuf.limit();
            // increase the byte buffer if it's free memory falls below 20 percent
            if ( headerBuf.remaining() <= (limit / 5) )
            {
                logger.log( Level.FINEST, "Allocating additional " + (limit / 2) + "b for buffer with " + limit + "b" );
                headerBuf = ByteBufferAllocator.reAllocate( headerBuf, limit + (limit / 2) );
View Full Code Here

                    .getAttachementInfo().toString() : HttpRequest.HTTP_POST );
            if ( !noBuffer ) request.addData( buffer );
            headerBuf = request.toByteBuffer();
            if ( logger.isLoggable( Level.FINEST ) )
            {
                logger.log( Level.FINEST, "Preparing to write client request with " + headerBuf.limit() + " bytes:\n"
                        + IOUtil.decodeToString( headerBuf ) );
            }
        }
        else
        {
View Full Code Here

                    .getAttachementInfo().toString() : HttpResponse.HTTP_OK );
            if ( !noBuffer ) response.addData( buffer );
            headerBuf = response.toByteBuffer();
            if ( logger.isLoggable( Level.FINEST ) )
            {
                logger.log( Level.FINEST, "Preparing to write server response with " + headerBuf.limit() + " bytes:\n"
                        + IOUtil.decodeToString( headerBuf ) );
            }
        }

        try
View Full Code Here

                if ( buffer != null && buffer.capacity() >= capacity )
                {
                    ref.clear();
                    _pool.remove( i );
                    _currentSize -= buffer.capacity();
                    buffer.limit( capacity );
                    LOG.log( Level.FINEST, "Borrowed buffer with capacity of " + buffer.capacity() + "(limit="
                            + capacity + "). Pool max size: " + _sizeB + " Current pool size: " + _currentSize );
                    return buffer;
                }
               
View Full Code Here

        } else if(bb.remaining() < len) {
            return false;
        }
        boolean success = false;
        int pos = bb.position();
        int lim = bb.limit();
        try {
            bb.limit(pos+len);
            ref.refer(bb, true);
            success = true;
        } finally {
View Full Code Here

        }
        boolean success = false;
        int pos = bb.position();
        int lim = bb.limit();
        try {
            bb.limit(pos+len);
            ref.refer(bb, true);
            success = true;
        } finally {
            bb.limit(lim);
            if(success) {
View Full Code Here

        try {
            bb.limit(pos+len);
            ref.refer(bb, true);
            success = true;
        } finally {
            bb.limit(lim);
            if(success) {
                bb.position(pos+len);
            } else {
                bb.position(pos);
            }
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.