Java Integer to intToFourBytes(int i)

Here you can find the source of intToFourBytes(int i)

Description

int To Four Bytes

License

Open Source License

Declaration

private static byte[] intToFourBytes(int i) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2016 Dr.-Ing. Marc M?ltin.
 *  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
 *
 *  Contributors://from  w w  w. j  a  v  a 2 s.  c om
 *    Dr.-Ing. Marc M?ltin - initial API and implementation and initial documentation
 *******************************************************************************/

public class Main {
    private static byte[] intToFourBytes(int i) {
        byte[] res = new byte[4];
        res[0] = (byte) (i >>> 24);
        res[1] = (byte) ((i >>> 16) & 0xFF);
        res[2] = (byte) ((i >>> 8) & 0xFF);
        res[3] = (byte) (i & 0xFF);
        return res;
    }
}

Related

  1. intToEncodedID(int input)
  2. IntToEnode62(Integer int10)
  3. IntToEnode62(Integer int10)
  4. intToFixedLengthString(int value, int length)
  5. intToFourByte(long value, byte[] dest, int off)
  6. intToFourBytes(int iValue, byte b[], int offset)
  7. intToFourChars(int value)
  8. intToGoodBadSimple(int i)
  9. intToID(int ID)