Java Byte Array Create toBytes(int value)

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

Description

to Bytes

License

Open Source License

Declaration

public static byte[] toBytes(int value) 

Method Source Code

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

public class Main {
    public static byte[] toBytes(int value) {
        byte[] result = new byte[4];
        for (int idx = 0; idx < 4; idx++) {
            result[idx] = (byte) (value & 0xFF);
            value = value >> 8;//from  ww  w .  jav a2s.  c  o  m
        }
        return result;
    }
}

Related

  1. toBytes(int megabytes)
  2. toBytes(int n)
  3. toBytes(int n)
  4. toBytes(int val)
  5. toBytes(int value)
  6. toBytes(int value)
  7. toBytes(int value)
  8. toBytes(int value)
  9. toBytes(int value, byte[] dest, int destPos)