集册 Java实例教程 获取Inet套接字地址

获取Inet套接字地址

欢马劈雪     最近更新时间:2020-01-02 10:19:05

378
获取Inet套接字地址
/*N o w  J a v a  . c o m 提供*/


//package com.nowjava;

import java.net.InetSocketAddress;

import java.util.ArrayList;

import java.util.List;


public class Main {

    public static void main(String[] argv) throws Exception {

        String address = "nowjava.com";

        System.out.println(getInetSocketAddress(address));

    }


    public static List<InetSocketAddress> getInetSocketAddress(

            String address) {

        List<InetSocketAddress> inetSocketAddresses = new ArrayList<InetSocketAddress>();

        String[] addresses = address.split(",");

        for (String dress : addresses) {

            String[] hosts = dress.split(":");

            inetSocketAddr
展开阅读全文