Advertisement
eldieck

Untitled

Jul 12th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. boolean isIPv4Address(String inputString) {
  2.        
  3.     String[] check = inputString.split(Pattern.quote("."));
  4.    
  5.     if(check.length == 4) {
  6.        
  7.         for(int i = 0; i < check.length; i++) {
  8.            
  9.             if(check[i].length() > 0 && check[i].matches("[0-9]{1,3}") && (Integer.parseInt(check[i]) > 255 || Integer.parseInt(check[i]) < 0)) {
  10.                
  11.                 return false;
  12.             }
  13.         }
  14.         return true;
  15.     }
  16.      return false;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement