标签:known print shm spi tac inter cti auth hashmap
1.InetAddress的应用
import java.util.List; import java.math.BigDecimal; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; import java.util.Stack; import javax.naming.spi.DirStateFactory.Result; import org.omg.PortableInterceptor.DISCARDING; import java.util.Map; import java.util.Queue; /** * InetAddress类 * @author 16114 * */ public class Main{ public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost(); System.out.println("计算机名:" + address.getHostName()); System.out.println("IP地址:" + address.getHostAddress()); byte[] bytes = address.getAddress(); System.out.println("字节数组形式的IP:" + Arrays.toString(bytes)); System.out.println(address); } catch (UnknownHostException e) { e.printStackTrace(); } try { InetAddress address2 = InetAddress.getByName("Roni"); System.out.println(address2.getHostName()); System.out.println(address2.getHostAddress()); } catch (UnknownHostException e) { e.printStackTrace(); } } }
标签:known print shm spi tac inter cti auth hashmap
原文地址:https://www.cnblogs.com/Roni-i/p/9788983.html