<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FNetwork_Protocol%2FNetworkInterface</id>
		<title>Java/Network Protocol/NetworkInterface - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FNetwork_Protocol%2FNetworkInterface"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Network_Protocol/NetworkInterface&amp;action=history"/>
		<updated>2026-04-11T14:45:37Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Network_Protocol/NetworkInterface&amp;diff=8895&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Network_Protocol/NetworkInterface&amp;diff=8895&amp;oldid=prev"/>
				<updated>2010-06-01T07:21:02Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:21, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Network_Protocol/NetworkInterface&amp;diff=8894&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Network_Protocol/NetworkInterface&amp;diff=8894&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:47Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== An updated version of the ListNets program that uses the NetworkInterface enhancements ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.io.Console;&lt;br /&gt;
import java.net.InetAddress;&lt;br /&gt;
import java.net.InterfaceAddress;&lt;br /&gt;
import java.net.NetworkInterface;&lt;br /&gt;
import java.net.SocketException;&lt;br /&gt;
import java.util.Arrays;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String args[]) throws SocketException {&lt;br /&gt;
    Enumeration&amp;lt;NetworkInterface&amp;gt; nets = NetworkInterface.getNetworkInterfaces();&lt;br /&gt;
    for (NetworkInterface netint : Collections.list(nets)) {&lt;br /&gt;
      displayInterfaceInformation(netint);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {&lt;br /&gt;
    System.out.printf(&amp;quot;Display name: %s%n&amp;quot;, netint.getDisplayName());&lt;br /&gt;
    System.out.printf(&amp;quot;Name: %s%n&amp;quot;, netint.getName());&lt;br /&gt;
    Enumeration&amp;lt;InetAddress&amp;gt; inetAddresses = netint.getInetAddresses();&lt;br /&gt;
    for (InetAddress inetAddress : Collections.list(inetAddresses)) {&lt;br /&gt;
      System.out.printf(&amp;quot;InetAddress: %s%n&amp;quot;, inetAddress);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.printf(&amp;quot;Parent: %s%n&amp;quot;, netint.getParent());&lt;br /&gt;
    System.out.printf(&amp;quot;Up? %s%n&amp;quot;, netint.isUp());&lt;br /&gt;
    System.out.printf(&amp;quot;Loopback? %s%n&amp;quot;, netint.isLoopback());&lt;br /&gt;
    System.out.printf(&amp;quot;PointToPoint? %s%n&amp;quot;, netint.isPointToPoint());&lt;br /&gt;
    System.out.printf(&amp;quot;Supports multicast? %s%n&amp;quot;, netint.isVirtual());&lt;br /&gt;
    System.out.printf(&amp;quot;Virtual? %s%n&amp;quot;, netint.isVirtual());&lt;br /&gt;
    System.out.printf(&amp;quot;Hardware address: %s%n&amp;quot;, Arrays.toString(netint.getHardwareAddress()));&lt;br /&gt;
    System.out.printf(&amp;quot;MTU: %s%n&amp;quot;, netint.getMTU());&lt;br /&gt;
    List&amp;lt;InterfaceAddress&amp;gt; interfaceAddresses = netint.getInterfaceAddresses();&lt;br /&gt;
    for (InterfaceAddress addr : interfaceAddresses) {&lt;br /&gt;
      System.out.printf(&amp;quot;InterfaceAddress: %s%n&amp;quot;, addr.getAddress());&lt;br /&gt;
    }&lt;br /&gt;
    System.out.printf(&amp;quot;%n&amp;quot;);&lt;br /&gt;
    Enumeration&amp;lt;NetworkInterface&amp;gt; subInterfaces = netint.getSubInterfaces();&lt;br /&gt;
    for (NetworkInterface networkInterface : Collections.list(subInterfaces)) {&lt;br /&gt;
      System.out.printf(&amp;quot;%nSubInterface%n&amp;quot;);&lt;br /&gt;
      displayInterfaceInformation(networkInterface);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.printf(&amp;quot;%n&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extract network card address with java.net.NetworkInterface ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.net.NetworkInterface;&lt;br /&gt;
import java.net.SocketException;&lt;br /&gt;
import java.util.Arrays;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String args[]) throws SocketException {&lt;br /&gt;
    Enumeration&amp;lt;NetworkInterface&amp;gt; nets = NetworkInterface&lt;br /&gt;
        .getNetworkInterfaces();&lt;br /&gt;
    while (nets.hasMoreElements()) {&lt;br /&gt;
      NetworkInterface netint = nets.nextElement();&lt;br /&gt;
      System.out.println(&amp;quot;Display name: &amp;quot; + netint.getDisplayName());&lt;br /&gt;
      System.out.println(&amp;quot;Hardware address: &amp;quot;&lt;br /&gt;
          + Arrays.toString(netint.getHardwareAddress()));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
} &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Get MAC address of a host: java.net.NetworkInterface.getHardwareAddress(). ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.net.InetAddress;&lt;br /&gt;
import java.net.NetworkInterface;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    InetAddress address = InetAddress.getLocalHost();&lt;br /&gt;
    NetworkInterface ni = NetworkInterface.getByInetAddress(address);&lt;br /&gt;
    byte[] mac = ni.getHardwareAddress();&lt;br /&gt;
    for (int i = 0; i &amp;lt; mac.length; i++) {&lt;br /&gt;
      System.out.format(&amp;quot;%02X%s&amp;quot;, mac[i], (i &amp;lt; mac.length - 1) ? &amp;quot;-&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== List Network Interfaces ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.net.NetworkInterface;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
public class Main {&lt;br /&gt;
  static public void main(String args[]) throws Exception {&lt;br /&gt;
    Enumeration interfaces = NetworkInterface.getNetworkInterfaces();&lt;br /&gt;
    while (interfaces.hasMoreElements()) {&lt;br /&gt;
      NetworkInterface ni = (NetworkInterface) interfaces.nextElement();&lt;br /&gt;
      System.out.println(ni);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programmatic Access to Network Parameters ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
import java.net.InetAddress;&lt;br /&gt;
import java.net.NetworkInterface;&lt;br /&gt;
import java.net.SocketException;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String args[]) throws SocketException {&lt;br /&gt;
    Enumeration&amp;lt;NetworkInterface&amp;gt; nets = NetworkInterface.getNetworkInterfaces();&lt;br /&gt;
    for (NetworkInterface netint : Collections.list(nets)) {&lt;br /&gt;
      displayInterfaceInformation(netint);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {&lt;br /&gt;
    System.out.printf(&amp;quot;Display name: %s%n&amp;quot;, netint.getDisplayName());&lt;br /&gt;
    System.out.printf(&amp;quot;Name: %s%n&amp;quot;, netint.getName());&lt;br /&gt;
    Enumeration&amp;lt;InetAddress&amp;gt; inetAddresses = netint.getInetAddresses();&lt;br /&gt;
    for (InetAddress inetAddress : Collections.list(inetAddresses)) {&lt;br /&gt;
      System.out.printf(&amp;quot;InetAddress: %s%n&amp;quot;, inetAddress);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.printf(&amp;quot;%n&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Report By Name ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.net.NetworkInterface;&lt;br /&gt;
public class Main {&lt;br /&gt;
  static public void main(String args[]) throws Exception {&lt;br /&gt;
    NetworkInterface ni = NetworkInterface.getByName(args[0]);&lt;br /&gt;
    System.out.println(ni);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>