Here you can find the source of isValidInetAddress(String address)
public static boolean isValidInetAddress(String address)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Robert "Unlogic" Olofsson (unlogic@unlogic.se). * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0-standalone.html ******************************************************************************/ import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static boolean isValidInetAddress(String address) { try {/* w w w. j a v a 2 s. com*/ InetAddress.getByName(address); return true; } catch (UnknownHostException e) { return false; } } }