Java Long Number Convert To convertLongToBytes(final long unsignedIntIp)

Here you can find the source of convertLongToBytes(final long unsignedIntIp)

Description

convert Long To Bytes

License

Open Source License

Declaration

private static byte[] convertLongToBytes(final long unsignedIntIp) 

Method Source Code

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

public class Main {
    private static byte[] convertLongToBytes(final long unsignedIntIp) {

        byte[] bytes = new byte[4];
        bytes[0] = (byte) ((unsignedIntIp & 0xFF000000L) >>> 24);
        bytes[1] = (byte) ((unsignedIntIp & 0x00FF0000L) >> 16);
        bytes[2] = (byte) ((unsignedIntIp & 0x0000FF00L) >> 8);
        bytes[3] = (byte) (unsignedIntIp & 0x000000FFL);

        return bytes;
    }/*w  w  w  . j a v  a2 s.  c  o  m*/
}

Related

  1. convertLongToBytes(long l)
  2. convertLongToCharSmall(long theLong)
  3. convertLongToCidr(long unsignedIntCidr)
  4. convertLongToDouble(final long[] longs)