package com.haoran.lesson; import java.net.InetSocketAddress; public class testport { public static void main(String[] args) { InetSocketAddress inetSocketAddress = new InetSocketAddress("127.0.0.1", 8080); //用来封装端口; System.out.println(inetSocketAddress.getAddress()); System.out.println(inetSocketAddress.getPort()); System.out.println(inetSocketAddress.getHostName()); } }