Java InetAddress Check formatAddresses( List addresses)

Here you can find the source of formatAddresses( List addresses)

Description

Format a list of InetAddress.

License

Apache License

Parameter

Parameter Description
addresses a List of <code>InetAddress</code> instances.

Return

a string containing a space-separated list of hostname|ip_address pairs.

Declaration

private static String formatAddresses(
        List<? extends InetAddress> addresses) 

Method Source Code

//package com.java2s;
/*/*from   ww w.  ja v a 2s .c  om*/
 * JPPF.
 * Copyright (C) 2005-2010 JPPF Team.
 * http://www.jppf.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.net.InetAddress;

import java.util.*;

public class Main {
    /**
     * Format a list of InetAddress.
     * @param addresses a List of <code>InetAddress</code> instances.
     * @return a string containing a space-separated list of <i>hostname</i>|<i>ip_address</i> pairs.
     */
    private static String formatAddresses(
            List<? extends InetAddress> addresses) {
        StringBuffer sb = new StringBuffer();
        for (InetAddress addr : addresses) {
            String name = addr.getHostName();
            String ip = addr.getHostAddress();
            if (sb.length() > 0)
                sb.append(" ");
            sb.append(name).append("|").append(ip);
        }
        return sb.toString();
    }
}

Related

  1. arrayToList(final InetAddress[] addresses)
  2. canTcpListen(InetAddress address, int port)
  3. checkIPMatch(String ipTemplateList, InetAddress addr)
  4. createRandomSocketAddressList( InetAddress bindAddress, int preferredPort, int minPort, int maxPort)
  5. getInetAddressList(NetworkInterface netInterface)
  6. is6to4(InetAddress addr)
  7. isAddressReachable(InetAddress address)
  8. isAny(InetAddress ip)