Here you can find the source of getHostAddress(final URI uri)
Parameter | Description |
---|---|
uri | a parameter |
public static InetAddress getHostAddress(final URI uri)
//package com.java2s; /*/*from www . j a va 2s .c o m*/ * Copyright (c) 2006 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial concept and implementation */ import java.net.InetAddress; import java.net.URI; public class Main { /** * Get the address of the host. * * <p><b>NOTE</b>: This may take a long time as it will perform a DNS lookup * which can take several seconds!</p> * * * @param uri * * @return The InetAddress of the host specified in the URI. Will return null * if DNS lookup fails, if the URI reference is null or if no host is * specified in the URI. */ public static InetAddress getHostAddress(final URI uri) { if (uri != null) { final String host = uri.getHost(); if (host != null) { try { return InetAddress.getByName(host); } catch (final Exception exception) { } } } return null; } }