Java Integer Create toInts(int val)

Here you can find the source of toInts(int val)

Description

Converts each byte in an integer to an integer, places them in MSB order.

License

LGPL

Parameter

Parameter Description
val Integer to separate.

Return

Array of shifted bytes as an int[].

Declaration

public static int[] toInts(int val) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**/*  w w w.  j av a  2s  .c  o m*/
     * Converts each byte in an integer to an integer, places them in MSB order.
     *
     * @param val Integer to separate.
     * @return Array of shifted bytes as an int[].
     */
    public static int[] toInts(int val) {
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[3 - i] = 0xFF & val;
            val >>= 8;
        }
        return ints;
    }
}

Related

  1. toInts(byte[] bytes)
  2. toInts(byte[] readBuffer, int o, int l)
  3. toInts(byte[] src, int srcOffset, int[] dst, int dstOffset, int length)
  4. toInts(byte[] value, int offset, int num)
  5. toInts(double[] arr)
  6. toInts(Integer[] values)
  7. toInts(long[] array)
  8. toInts(String intArray)
  9. toInts(String[] values)