My IP Address and Host Name in JAVA

Get my IP Address and Host Name in JAVA

import java.net.InetAddress;

public class Main {

    public static void main(String[] args){
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            System.out.println("IP Address:  " + inetAddress.getHostAddress());
            System.out.println("Host Name: " + inetAddress.getHostName());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}