Here you can find the source of intToByteArray4(int i)
Parameter | Description |
---|---|
i | the integer number |
public static byte[] intToByteArray4(int i)
//package com.java2s; /*//from ww w .j av a 2 s . co m * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ public class Main { /** * Converts an integer number into a 4 bytes array * * @param i the integer number * @return the byte array */ public static byte[] intToByteArray4(int i) { return new byte[] { (byte) ((i >> 24) & 0xff), (byte) ((i >> 16) & 0xff), (byte) ((i >> 8) & 0xff), (byte) (i & 0xff) }; } }