how to validate the ip address in java

how to validate the ip address in java
refer ‮ual:ot‬tturi.com
/**
 * @author lautturi.com 
 * Java example: validate the ip address in java using regular expression. 
 */


import java.util.*;
import java.util.regex.*;

public class Lautturi {

	public static void main(String[] args) {
		String IP = "192.168.1.100";
		String pattern = 
	            "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
	            "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
	            "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
	            "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
        System.out.println(IP.matches(pattern));
	}
}
Created Time:2017-10-07 14:53:39  Author:lautturi