Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.net.InetAddress;

import java.net.UnknownHostException;

import android.util.Log;

public class Main {
    private static String Tag = "Helper";

    public static String getHostName(String ip) {
        String hostName = "Unknown";

        try {
            InetAddress add = InetAddress.getByName(ip);
            hostName = add.getHostName();

            Log.d(Tag, "host name is " + hostName);
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return hostName;
    }
}