Java InetAddress from intToInetAddress(int i)

Here you can find the source of intToInetAddress(int i)

Description

int To Inet Address

License

Apache License

Declaration

public static InetAddress intToInetAddress(int i) throws UnknownHostException 

Method Source Code


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

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {
    public static InetAddress intToInetAddress(int i) throws UnknownHostException {
        return InetAddress.getByAddress(intToAddress(i));
    }/*from  w  ww . j  a va 2s. c o  m*/

    public static byte[] intToAddress(int i) {
        return new byte[] { (byte) ((i >> 24) & 0xFF), (byte) ((i >> 16) & 0xFF), (byte) ((i >> 8) & 0xFF),
                (byte) (i & 0xFF) };
    }
}

Related

  1. inetAddress(String host)
  2. int2InetAddress(int val)
  3. IntegerToInetAddress(int ipAddress)
  4. ip2Long(InetAddress ip)
  5. ipToBytesByInetAddress(String ip)
  6. ipToLong(InetAddress ip)
  7. long2InetAddress(long val)