Here you can find the source of getHostName(String localAddress)
Parameter | Description |
---|---|
localAddress | the local address |
public static String getHostName(String localAddress)
//package com.java2s; /*/*from ww w . j ava2 s . c o m*/ * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (http://h2database.com/html/license.html). * Initial Developer: H2 Group */ import java.net.InetAddress; public class Main { /** * Get the host name of a local address, if available. * * @param localAddress the local address * @return the host name, or another text if not available */ public static String getHostName(String localAddress) { try { InetAddress addr = InetAddress.getByName(localAddress); return addr.getHostName(); } catch (Exception e) { return "unknown"; } } }