Java ByteBuffer Set resetBit(ByteBuffer in, int pos)

Here you can find the source of resetBit(ByteBuffer in, int pos)

Description

Sets the bit in given input to zero Sets the pos bit in input to zero

License

Open Source License

Parameter

Parameter Description
in The input ByteBuffer
pos The position in the input ByteBuffer to set.

Declaration


public static final void resetBit(ByteBuffer in, int pos) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from   www.j a va 2s  .co  m
 *     IBM Corporation - Initial API and implementation
 *******************************************************************************/

import java.nio.ByteBuffer;

public class Main {
    /** A constant equal to the number of bits per byte */
    public static final int NBITS_PER_BYTE = 8;

    /**
     * Sets the bit in given input to zero
     * 
     * Sets the pos bit in input to zero
     * 
     * @param in
     *            The input ByteBuffer
     * @param pos
     *            The position in the input ByteBuffer to set.
     */

    public static final void resetBit(ByteBuffer in, int pos) {
        in.put(pos >> 3, (byte) (in.get(pos >> 3) & ~(1 << (pos % NBITS_PER_BYTE))));
    }
}

Related

  1. redByteArray(ByteBuffer buffer, int offset, int length)
  2. redInteger1(ByteBuffer buffer, int _offset)
  3. redString(ByteBuffer buffer, int offset, Charset charset)
  4. releaseTemporaryDirectBuffer(ByteBuffer buf)
  5. reset(int offset, ByteBuffer b)
  6. set0byte(MappedByteBuffer mem, byte value)
  7. set24BitInt(ByteBuffer buffer, int value)
  8. setBatch(ByteBuffer bb, long batchId)
  9. setByteOrder(ByteBuffer buffer)