Java InetAddress convertLongToInetAddress(long address)

Here you can find the source of convertLongToInetAddress(long address)

Description

convert Long To Inet Address

License

LGPL

Declaration

public static InetAddress convertLongToInetAddress(long address)
            throws UnknownHostException 

Method Source Code

//package com.java2s;
/*//from  ww w. java  2s  . c  o  m
 * IRClib -- A Java Internet Relay Chat library -- class IRCConnection
 * Copyright (C) 2002 - 2006 Christoph Schwering <schwering@gmail.com>
 * 
 * This library and the accompanying materials are made available under the
 * terms of the
 *    - GNU Lesser General Public License,
 *    - Apache License, Version 2.0 and
 *    - Eclipse Public License v1.0.
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY.
 */

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

public class Main {
    public static InetAddress convertLongToInetAddress(long address)
            throws UnknownHostException {
        byte[] addr = new byte[4];
        addr[0] = (byte) ((address >>> 24) & 0xFF);
        addr[1] = (byte) ((address >>> 16) & 0xFF);
        addr[2] = (byte) ((address >>> 8) & 0xFF);
        addr[3] = (byte) (address & 0xFF);
        return InetAddress.getByAddress(addr);
    }
}

Related

  1. compareInetAddresses(InetAddress a1, InetAddress a2)
  2. CompareIP(InetAddress ip1, InetAddress ip2)
  3. contains(InetAddress network, InetAddress netmask, InetAddress ip)
  4. convertInetAddressToLong(InetAddress addr)
  5. convertInetAddressToLong(InetAddress address)
  6. createAbsoluteURL(InetAddress address, int localStreamPort, URI relativeOrNot)
  7. createDatagramSocket(InetAddress addr, int port)
  8. createInetSocketAddress(final InetAddress address)
  9. createResolved(InetAddress address, int port)