get Single InetSocketAddress - Java Network

Java examples for Network:Network Address

Description

get Single InetSocketAddress

Demo Code


//package com.java2s;
import java.net.InetSocketAddress;

public class Main {
    public static void main(String[] argv) throws Exception {
        String address = "java2s.com";
        Integer port = 2;//from   w w  w.  j a v a2 s . c  o  m
        System.out.println(getSingle(address, port));
    }

    private static final int DEFAULT_PORT = 80;

    public static InetSocketAddress getSingle(String address, Integer port) {

        if (port == null) {
            port = DEFAULT_PORT;
        }

        return new InetSocketAddress(address, port);
    }
}

Related Tutorials