find your ip address code example

Example 1: get your ip address from terminal

for local ip :

hostname -I

for Public ip :

curl icanhazip.com

Example 2: how to find ip address

import java.net.InetAddress;
import java.net.UnknownHostException;
public class FindIPaddress {
	public static void main(String[] args) throws UnknownHostException {
		InetAddress a = InetAddress.getLocalHost();
		System.out.println(a.getHostAddress());	
	}
}

Example 3: check ip address using cmd

@echo off
setlocal
mode con:cols=110 lines=30

:start
cls

set /p localWireless=add adb local wireless usb ip address ? &
echo %localWireless% | findstr /i /r [A-za-z]
cls

if %errorlevel% equ 1 (
  msg %username% 'ip address is valid'
  goto start
) else (
  msg %username% 'ip address is not valid'
  goto start
)

pause
goto start