Code example for StringTokenizer

Methods: hasMoreTokens, nextToken

0
            Thread.sleep(40000);
        } 
    } 
 
    static InetSocketAddress from(String endpoint) {
        StringTokenizer tokes = new StringTokenizer(endpoint, ":");
        if (tokes.hasMoreTokens()) {
            String host = tokes.nextToken();
            if (tokes.hasMoreTokens()) {
                int port = Integer.parseInt(tokes.nextToken());
                return new InetSocketAddress(host, port);
            } 
            throw new IllegalArgumentException("No port: " + endpoint);
        } 
        throw new IllegalArgumentException("Invalid host:port specification: "
                                           + endpoint);
    } 
 
    @Bean 
    public HeartbeatConfiguration heartbeatConfig() { 
        return new HeartbeatConfiguration(3000, 2);