Java IP Address Validate isIP(String ipString)

Here you can find the source of isIP(String ipString)

Description

is IP

License

Open Source License

Declaration

public static boolean isIP(String ipString) 

Method Source Code

//package com.java2s;
/*//  w w w .j a va  2 s  .c  o m
 * AdcUtils.java
 *
 * Created on 04 martie 2007, 13:20
 *
 * DSHub AdcUtils HubSoft
 * Copyright (C) 2007,2008  Eugen Hristev
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.util.regex.Pattern;

public class Main {
    private static final Pattern COMPILE = Pattern
            .compile("\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
                    + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
                    + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
                    + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");

    public static boolean isIP(String ipString) {
        return COMPILE.matcher(ipString).matches();
    }
}

Related

  1. isIp(Object obj)
  2. isIP(String input)
  3. isIp(String ip)
  4. isIP(String ip)
  5. isIp(String ipAddress)
  6. isIp(String s)
  7. isIP(String src)
  8. isIP(String str)
  9. isIp(String str)