Here you can find the source of intToBytes(int value, byte[] array, int offset)
Parameter | Description |
---|---|
array | The array of bytes. |
offset | The offset from which to start marshalling. |
public static void intToBytes(int value, byte[] array, int offset)
//package com.java2s; /*//w w w . j av a 2s . c o m * %W% %E% * * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { /** Marshal an integer to a byte array. The bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+3] is the least-significant-byte. @param array The array of bytes. @param offset The offset from which to start marshalling. */ public static void intToBytes(int value, byte[] array, int offset) { array[offset++] = (byte) ((value >>> 24) & 0xFF); array[offset++] = (byte) ((value >>> 16) & 0xFF); array[offset++] = (byte) ((value >>> 8) & 0xFF); array[offset++] = (byte) ((value >>> 0) & 0xFF); } }