I want to verify an IP address in java, how can I do that? The IP Address needs to be in this format: xxx.xxx.xxx.xxx Each octet range must be 0 ~ 255.
Since the IP is verified, the code must show a message telling that the IP is valid or not. If not, the user must type the IP again.
I've done the method to convert an IP string to an array of integers so far...
public static void verify() {
Scanner input = new Scanner(System.in);
System.out.println("IP: (xxx.xxx.xxx.xxx)");
String ipAddress = input.nextLine();
int[] arrayIpAddress = Arrays.stream(ipAddress.split("\\.")).mapToInt(Integer::parseInt).toArray();
}