Example usage for java.net Inet6Address getByAddress

List of usage examples for java.net Inet6Address getByAddress

Introduction

In this page you can find the example usage for java.net Inet6Address getByAddress.

Prototype

public static InetAddress getByAddress(String host, byte[] addr) throws UnknownHostException 

Source Link

Document

Creates an InetAddress based on the provided host name and IP address.

Usage

From source file:org.getlantern.firetweet.util.net.FiretweetHostAddressResolver.java

private InetAddress[] fromAddressString(String host, String address) throws UnknownHostException {
    InetAddress inetAddress = InetAddress.getByName(address);
    if (inetAddress instanceof Inet4Address) {
        return new InetAddress[] { Inet4Address.getByAddress(host, inetAddress.getAddress()) };
    } else if (inetAddress instanceof Inet6Address) {
        return new InetAddress[] { Inet6Address.getByAddress(host, inetAddress.getAddress()) };
    }/* w w w .ja va  2 s  .  c o m*/
    throw new UnknownHostException("Bad address " + host + " = " + address);
}