Code:
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String str = sc.next();
System.out.println(Pattern.matches("^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", str));
}
}
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String str = sc.next();
System.out.println(Pattern.matches("^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", str));
}
}