public static Hosts parse(String hostString, Integer explicitGlobalPort, Integer defaultPort) {
		List<String> hosts = new ArrayList<>();
		List<Integer> ports = new ArrayList<>();
		if ( hostString == null || hostString.trim().isEmpty() ) {
			return Hosts.NO_HOST;
		}
		// for each element between commas
		String[] splits = hostString.split( "," );
		for ( String rawSplit : splits ) {
			// remove whitespaces
			String split = rawSplit.trim();
			//
			Matcher matcher = HOST_AND_PORT_PATTERN.matcher( split );
			if ( matcher.matches() ) {
				setCleanHost( matcher, hosts );
				setPort( ports, matcher, explicitGlobalPort, splits, defaultPort );
			}
			else {
				throw LOG.unableToParseHost( hostString );
			}
		}
		return new Hosts( hosts, ports );
	}
public static Hosts parse ( String hostString , Integer explicitGlobalPort , Integer defaultPort ) { List < String > hosts = new ArrayList < > ( ) ; List < Integer > ports = new ArrayList < > ( ) ; if ( hostString == null || hostString . trim ( ) . isEmpty ( ) ) { return Hosts . NO_HOST ; } String [ ] splits = hostString . split ( "," ) ; for ( String rawSplit : splits ) { String split = rawSplit . trim ( ) ; Matcher matcher = HOST_AND_PORT_PATTERN . matcher ( split ) ; if ( matcher . matches ( ) ) { setCleanHost ( matcher , hosts ) ; setPort ( ports , matcher , explicitGlobalPort , splits , defaultPort ) ; } else { throw LOG . unableToParseHost ( hostString ) ; } } return new Hosts ( hosts , ports ) ; }
Accepts a comma separated list of host / ports.

For example

www.example.com, www2.example.com:123, 192.0.2.1, 192.0.2.2:123, 2001:db8::ff00:42:8329, [2001:db8::ff00:42:8329]:123