List of usage examples for com.google.common.net InetAddresses isInetAddress
public static boolean isInetAddress(String ipString)
From source file:org.dcache.ftp.door.Help.java
protected InetSocketAddress getExtendedAddressOf(String arg) throws FTPCommandException { try {/*from w w w. j av a 2 s. c o m*/ checkFTPCommand(!arg.isEmpty(), 501, "Syntax error: empty arguments."); ArrayList<String> splitted = Lists.newArrayList(Splitter.on(arg.charAt(0)).split(arg)); checkFTPCommand(splitted.size() == 5, 501, "Syntax error: Wrong number of arguments in '%s'.", arg); Protocol protocol = Protocol.find(splitted.get(1)); checkFTPCommand(InetAddresses.isInetAddress(splitted.get(2)), 501, "Syntax error: '%s' is no valid address.", splitted.get(2)); InetAddress address = InetAddresses.forString(splitted.get(2)); checkFTPCommand(protocol.getAddressClass().equals(address.getClass()), 501, "Protocol code does not match address: '%s'.", arg); int port = Integer.parseInt(splitted.get(3)); checkFTPCommand(port >= 1 && port <= 65536, 501, "Port number '%d' out of range [1,65536].", port); return new InetSocketAddress(address, port); } catch (NumberFormatException nfe) { throw new FTPCommandException(501, "Syntax error: no valid port number in '" + arg + "'."); } }