Java ByteBuffer Put putIntArray(int ints[], ByteBuffer bb)

Here you can find the source of putIntArray(int ints[], ByteBuffer bb)

Description

put Int Array

License

Open Source License

Declaration

static public ByteBuffer putIntArray(int ints[], ByteBuffer bb) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2007(c) G?nome Qu?bec. All rights reserved.
 * /*from  w  w  w  . j  av  a 2  s  .co  m*/
 * This file is part of GenoByte.
 * 
 * GenoByte is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 * 
 * GenoByte is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 *******************************************************************************/

import java.nio.ByteBuffer;

public class Main {
    static public ByteBuffer putIntArray(int ints[], ByteBuffer bb) {
        if (ints != null) {
            bb.putInt(ints.length);
            byte[] b = new byte[ints.length * 4];
            int l = 0;
            for (int i = 0; i < b.length;) {
                int x = ints[l++];
                b[i++] = (byte) (x >> 24);
                b[i++] = (byte) (x >> 16);
                b[i++] = (byte) (x >> 8);
                b[i++] = (byte) (x >> 0);
            }
            bb.put(b);
        } else {
            bb.putInt(-1);
        }
        return bb;
    }
}

Related

  1. putDecInt(ByteBuffer buffer, int n)
  2. putInt(ByteBuffer bb, long value)
  3. putInt(ByteBuffer buffer, int val, ByteOrder order)
  4. putInt(final ByteBuffer buffer, int value)
  5. putInt(int i, ByteBuffer buffer)
  6. putIntByteBuffer(ByteBuffer buf, int b)
  7. putIntByteBuffer(ByteBuffer buf, int b)
  8. putIntLSBMSB(ByteBuffer byteBuffer, int value)
  9. putNAL(ByteBuffer codecPrivate, ByteBuffer byteBuffer, int nalType)