You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/10 12:28:21 UTC

svn commit: r813356 - /commons/sandbox/runtime/trunk/src/main/native/test/PrintSystemProperties.java

Author: mturk
Date: Thu Sep 10 10:28:21 2009
New Revision: 813356

URL: http://svn.apache.org/viewvc?rev=813356&view=rev
Log:
Dump network interfaces info

Modified:
    commons/sandbox/runtime/trunk/src/main/native/test/PrintSystemProperties.java

Modified: commons/sandbox/runtime/trunk/src/main/native/test/PrintSystemProperties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/PrintSystemProperties.java?rev=813356&r1=813355&r2=813356&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/PrintSystemProperties.java (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/PrintSystemProperties.java Thu Sep 10 10:28:21 2009
@@ -1,8 +1,25 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import java.io.*;
+import java.net.*;
 import java.util.*;
 
 /**
- * Print all system properties
+ * Print various system properties
  */
 public class PrintSystemProperties
 {
@@ -24,7 +41,7 @@
         Map        em = System.getenv();
         TreeSet    es = new TreeSet(em.keySet());
         for (Iterator<String> i = es.iterator(); i.hasNext();) {
-            String n = (String)i.next();
+            String n = i.next();
             System.out.println(n + " ->  " + em.get(n));
         }
 
@@ -33,10 +50,44 @@
         Properties ps = System.getProperties();
         TreeSet    ts = new TreeSet(ps.keySet());
         for (Iterator<String> i = ts.iterator(); i.hasNext();) {
-            String n = (String)i.next();
+            String n = i.next();
             System.out.println(n + " ->  " + ps.get(n));
         }
         System.out.println();
+        System.out.println("Network interfaces: ");
+        System.out.println("LVPMU (L)oopback (V)irtual (P)ointToPoint (M)multicastSupport (U)p");
+        try {
+            for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
+                NetworkInterface n = e.nextElement();
+                char [] flags = { '-', '-', '-', '-', '-'};
+                if (n.isLoopback())
+                    flags[0] = 'x';
+                if (n.isVirtual())
+                    flags[1] = 'x';
+                if (n.isPointToPoint())
+                    flags[2] = 'x';
+                if (n.supportsMulticast())
+                    flags[3] = 'x';
+                if (n.isUp())
+                    flags[4] = 'x';
+                System.out.print(new String(flags) + "\t" + n.getName() + "\t");
+                for (Enumeration<NetworkInterface> i = n.getSubInterfaces(); i.hasMoreElements();) {
+                    NetworkInterface s = i.nextElement();
+                    System.out.print( " [" + s.getName() + "]");
+                }
+                System.out.println(" -> " + n.getDisplayName());
+                List<InterfaceAddress> i = n.getInterfaceAddresses();
+                if (!i.isEmpty()) {
+                    for (int x = 0; x < i.size(); x++) {
+                        InterfaceAddress a = i.get(x);
+                        System.out.println("\t" + a.toString());
+                    }
+                }
+            }
+        } catch (SocketException e) {
+            // Ignore
+        }
+        System.out.println();
     }
 }