Here you can find the source of byteArrayFromInteger(int integer)
Parameter | Description |
---|---|
integer | The integer to convert |
public static byte[] byteArrayFromInteger(int integer)
//package com.java2s; /**//from w w w . jav a 2 s . c om * This code is free software; you can redistribute it and/or modify it under * the terms of the new BSD License. * * Copyright (c) 2008-2011, Sebastian Staudt */ public class Main { /** * Convert an integer value into the corresponding byte array * * @param integer The integer to convert * @return The byte array representing the given integer */ public static byte[] byteArrayFromInteger(int integer) { return new byte[] { (byte) (integer >> 24), (byte) (integer >> 16), (byte) (integer >> 8), (byte) integer }; } }