iscomar001
11/30/2018 - 11:14 PM

IP

Get IP java hostname Obtener IP

public static String getIp(){
    try {
        String IP = "";
        //OMAR Campañas aqui se genera el query para el preview
        InetAddress miIP = InetAddress.getLocalHost();
        IP = miIP.getHostAddress();
        return IP;
    } catch (UnknownHostException ex) {
        System.out.println(ex.getMessage());
    }
    return "";
}
public static String getHost(){
    String usuarioWindows = "";
    try {
        //OMAR Campañas aqui se genera el query para el preview
        InetAddress miIP = InetAddress.getLocalHost();
        usuarioWindows = miIP.getHostName();
        return usuarioWindows;
    } catch (UnknownHostException ex) {
        System.out.println(ex.getMessage());
    }
    return usuarioWindows;
}