Here you can find the source of intToBytes(int ipInt)
Parameter | Description |
---|---|
ipInt | a parameter |
public static byte[] intToBytes(int ipInt)
//package com.java2s; //License from project: Open Source License public class Main { private final static int INADDRSZ = 4; /**/*w w w.j av a 2 s .c om*/ * ipInt -> byte[] * * @param ipInt * @return byte[] */ public static byte[] intToBytes(int ipInt) { byte[] ipAddr = new byte[INADDRSZ]; ipAddr[0] = (byte) ((ipInt >>> 24) & 0xFF); ipAddr[1] = (byte) ((ipInt >>> 16) & 0xFF); ipAddr[2] = (byte) ((ipInt >>> 8) & 0xFF); ipAddr[3] = (byte) (ipInt & 0xFF); return ipAddr; } }