- import java.net.InetAddress;
- import java.net.NetworkInterface;
- import java.util.Enumeration;
- public class F {
- public static void main(String[] args) throws Exception
- {
- Enumeration<NetworkInterface> ni=NetworkInterface.getNetworkInterfaces();
- while(ni.hasMoreElements())
- {
- NetworkInterface list=ni.nextElement();
- Enumeration<InetAddress> ia=list.getInetAddresses();
- while(ia.hasMoreElements())
- {
- InetAddress ias=ia.nextElement();
- NetworkInterface n=NetworkInterface.getByInetAddress(ias);
- if(ias.getHostName()!=null&&!"".equalsIgnoreCase(ias.getHostName())&&ias.getHostAddress()!=null&&!"".equalsIgnoreCase(ias.getHostAddress())&&list.getName()!=null&&!"".equalsIgnoreCase(list.getName())&&list.getDisplayName()!=null&&!"".equalsIgnoreCase(list.getDisplayName()))
- {
- System.out.print(list.getName());
- System.out.println("\t网卡名字:\t"+list.getDisplayName());
- System.out.print("\t\t"+ias.getHostName());
- System.out.println("\t"+ias.getHostAddress());
- System.out.println("------------------------------");
- }
- }
- }
- }
- }
复制代码
这是完整答案,没听说过多点传送,只听说过点对点传送 |