Java Integer Convert To fromInt(int value)

Here you can find the source of fromInt(int value)

Description

from Int

License

Open Source License

Declaration

public static byte[] fromInt(int value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] fromInt(int value) {
        return fromLong(value, 4);
    }//from  w  ww . j a va2  s.  co  m

    public static byte[] fromLong(long value, int numBytes) {
        long mask = 0xFF;
        byte[] res = new byte[numBytes];
        for (int i = 0; i < numBytes; i++) {
            res[i] = (byte) (value & mask);
            value = value >> 8;
        }
        return res;
    }
}

Related

  1. fromInt(int input)
  2. fromInt(int intValue)
  3. fromInt(int key)
  4. fromInt(int value)
  5. fromInt(int value)
  6. fromInt(int value, byte[] arr, int offset)
  7. fromInt(int x, int size)
  8. fromInteger(int idx, Class clazz)
  9. fromInteger(int value)