Check if it is virtual network in Java

Description

The following code shows how to check if it is virtual network.

Example


import java.net.NetworkInterface;
import java.util.Enumeration;
//w  w w.j  a  v a2s .c o  m
public class Main {
  public static void main(String[] args) throws Exception {
    Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
    while (en.hasMoreElements()) {
      NetworkInterface ni = en.nextElement();
      System.out.println(" Display Name = " + ni.getDisplayName());
      System.out.println(" Is virtual = " + ni.isVirtual());
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode