Java ByteBuffer Put putUnsignedInt(final ByteBuffer dst, final long value)

Here you can find the source of putUnsignedInt(final ByteBuffer dst, final long value)

Description

Put an unsigned int in the ByteBuffer at the current position.

License

Apache License

Parameter

Parameter Description
dst the ByteBuffer to store the int
value the long which contains the unsigned int to store

Declaration

public static final void putUnsignedInt(final ByteBuffer dst, final long value) 

Method Source Code


//package com.java2s;
/*/*from  ww w  .ja  v  a2  s . co  m*/
 * #%L
 * Project eguan
 * %%
 * Copyright (C) 2012 - 2015 Oodrive
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.nio.ByteBuffer;

public class Main {
    private static final long INT_FLAG_MASK_LONG = 0x00000000FFFFFFFFL;

    /**
     * Put an unsigned int in the {@link ByteBuffer} at the current position.
     * 
     * @param dst
     *            the {@link ByteBuffer} to store the int
     * @param value
     *            the long which contains the unsigned int to store
     */
    public static final void putUnsignedInt(final ByteBuffer dst, final long value) {
        dst.putInt((int) (value & INT_FLAG_MASK_LONG));
    }
}

Related

  1. putTruncatedInt(ByteBuffer bytes, int value, int numBytes)
  2. putUInt16(ByteBuffer buffer, long value)
  3. putUInt32(ByteBuffer buffer, long value)
  4. putUnsignedByte(ByteBuffer bb, int value)
  5. putUnsignedInt(ByteBuffer buffer, long value)
  6. putUnsignedShort(ByteBuffer bytes, int value)
  7. putUUID(ByteBuffer bytes, UUID uuid)
  8. putVarint(ByteBuffer buffer, long number, int byteSize)
  9. putVInt(ByteBuffer b, int i)