Java Integer to Byte Array intToByteLittleEnding(int j)

Here you can find the source of intToByteLittleEnding(int j)

Description

int To Byte Little Ending

License

Apache License

Declaration

private static byte[] intToByteLittleEnding(int j) 

Method Source Code

//package com.java2s;
/* ====================================================================
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.//from w  w  w .  j  a  v  a  2  s  . co m
 ==================================================================== */

public class Main {
    private static byte[] intToByteLittleEnding(int j) {
        final byte[] bytes = new byte[4];
        bytes[0] = (byte) (j & 0xff);
        bytes[1] = (byte) ((j >>> 8) & 0xff);
        bytes[2] = (byte) ((j >>> 16) & 0xff);
        bytes[3] = (byte) ((j >>> 24) & 0xff);

        return bytes;
    }
}

Related

  1. intToByteArray2(final int integer)
  2. intToByteArray4(int i)
  3. intToByteArray4(int value)
  4. intToByteArrayBE(int data)
  5. intToByteArrayLE(int v)
  6. intToByteMSB(int in)
  7. intToBytes(byte[] arr, int offset, int num)
  8. intToBytes(byte[] bytes, int index, int value)
  9. intToBytes(final int aInt)