Here you can find the source of putIntArray(int ints[], ByteBuffer bb)
static public ByteBuffer putIntArray(int ints[], ByteBuffer bb)
//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; } }