注意字符串分割 "." 直接识别不了,要用"\\."

import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String str = sc.nextLine();
            String [] arr = str.split("\\.");
            boolean flag = true;
            for( String s : arr){
                int n = Integer.parseInt(s);
                if(n < 0 || n > 255){
                    flag = false;
                }
            }
            if(flag){
                System.out.println("YES");
            }else{
                System.out.println("NO");
                
            }
        }
    }
}