Java InetAddress Create getInetAddress(String name)

Here you can find the source of getInetAddress(String name)

Description

Get an InetAddress by name returning null if there is an error resolving the name.

License

Open Source License

Declaration

public static InetAddress getInetAddress(String name) 

Method Source Code

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

import java.net.*;

public class Main {
    /**// www. j  a  v a2s  . c  o  m
     * Get an InetAddress by name returning {@code null} if there is an error
     * resolving the name.
     */
    public static InetAddress getInetAddress(String name) {
        try {
            return InetAddress.getByName(name);
        } catch (Exception ex) {
            return null;
        }

    }

    /**
     * Create and return an InetAddress from the given array of octets returning
     * {@code null} if there are any errors instead of throwing an exception.
     */
    public static InetAddress getInetAddress(byte[] addrBytes) {
        try {
            return InetAddress.getByAddress(addrBytes);
        } catch (Exception ex) {
            return null;
        }

    }
}

Related

  1. getInetAddress(long ip)
  2. getInetAddress(Socket socket)
  3. getInetAddress(String dottedNotation)
  4. getInetAddress(String host)
  5. getInetAddress(String hostName)
  6. getInetAddress(String str)
  7. getInetAddressByName(String name)
  8. getInetAddresses()
  9. getInetAddresses(String filter)