Here you can find the source of formatAddresses( List extends InetAddress> addresses)
Parameter | Description |
---|---|
addresses | a List of <code>InetAddress</code> instances. |
private static String formatAddresses( List<? extends InetAddress> addresses)
//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(); } }