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;

public class Main {
    public static String getServiceIp(String host) {
        InetAddress myServer = null;
        try {
            myServer = InetAddress.getByName(host);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        if (myServer == null) {
            return "0";
        }
        return myServer.getHostAddress();
    }
}