Java Integer to Byte Array int32ToByteArray(int integer)

Here you can find the source of int32ToByteArray(int integer)

Description

int To Byte Array

License

Open Source License

Declaration

public static byte[] int32ToByteArray(int integer) 

Method Source Code

//package com.java2s;
/*//from w w  w  . j ava2  s. co m
 * This file is part of jtrfp.
 *
 * jtrfp 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.
 *
 * jtrfp 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 jtrfp.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static byte[] int32ToByteArray(int integer) {
        return new byte[] { (byte) integer, (byte) (integer >> 8), (byte) (integer >> 16), (byte) (integer >> 24) };
    }
}

Related

  1. int32ToArray(int data)
  2. int32ToArrayInPlace(int data, byte[] buffer, int offset)
  3. int32ToByteArr(int val, byte[] arr, int offset)
  4. int32ToByteArray(int a)
  5. int32toByteArray(int i)
  6. int32ToByteArray(int value)
  7. integerToByteArray(final int integerToSerialize, final byte[] byteArray, final int offset)
  8. integerToByteArray(int a, byte[] buf)
  9. integerToByteArray(int value)