Here you can find the source of isIPAddress(String line)
Parameter | Description |
---|---|
line | a parameter |
public static boolean isIPAddress(String line)
//package com.java2s; /**//from w w w . j a v a 2s . co m * This software is licensed under the MIT license. * If you wish to modify this software please give credit and link to the git: https://github.com/Moudoux/OTIRC. */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /** * Checks if a string is a ip address * * @param line * @return */ public static boolean isIPAddress(String line) { Pattern p = Pattern.compile( "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); Matcher m = p.matcher(line); if (m.find()) { return true; } return false; } }