Here you can find the source of int2Arr(int var, byte[] arrayBytes, int startIndex)
Parameter | Description |
---|---|
var | the int to encode |
arrayBytes | The byte array to store into. |
startIndex | index data to begin write. |
public static void int2Arr(int var, byte[] arrayBytes, int startIndex)
//package com.java2s; /* DielmoOpenLiDAR//from w w w .java 2s . c om * * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures * and Transports Department of the Valencian Government (CIT) * * This program 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 2 * of the License, or (at your option) any later version. * * This program 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * For more information, contact: * * DIELMO 3D S.L. * Plaza Vicente Andr?s Estell?s 1 Bajo E * 46950 Xirivella, Valencia * SPAIN * * +34 963137212 * dielmo@dielmo.com * www.dielmo.com * * or * * Generalitat Valenciana * Conselleria d'Infraestructures i Transport * Av. Blasco Ib??ez, 50 * 46010 VALENCIA * SPAIN * * +34 963862235 * gvsig@gva.es * www.gvsig.gva.es */ public class Main { /** * Write the bytes of "var" into new byte array. * * @param var the int to encode * @param arrayBytes The byte array to store into. * @param startIndex index data to begin write. */ public static void int2Arr(int var, byte[] arrayBytes, int startIndex) { int length = 4; if (arrayBytes != null && startIndex + length <= arrayBytes.length) { for (int j = startIndex; j < startIndex + length; j++) { arrayBytes[j] = (byte) var; // se copian los 8 primeros bits de la variable var >>= 8; } } } }