1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test 26 * @summary NOT A TEST. Captures the network interface configuration. 27 * @library /test/lib 28 * @run main NetworkConfigurationProbe 29 */ 30 31 import java.net.Inet4Address; 32 import java.net.Inet6Address; 33 import java.net.NetworkInterface; 34 import jdk.test.lib.NetworkConfiguration; 35 import static java.util.stream.Collectors.joining; 36 import static java.lang.System.out; 37 38 /** 39 * Not a test. Captures the network interface configuration. 40 */ 41 public class NetworkConfigurationProbe { 42 43 public static void main(String... args) throws Exception { 44 NetworkConfiguration.printSystemConfiguration(out); 45 46 NetworkConfiguration nc = NetworkConfiguration.probe(); 47 String list; 48 list = nc.ip4MulticastInterfaces() 49 .map(NetworkInterface::getName) 50 .collect(joining(" ")); 51 out.println("ip4MulticastInterfaces: " + list); 52 53 list = nc.ip4Addresses() 54 .map(Inet4Address::toString) 55 .collect(joining(" ")); 56 out.println("ip4Addresses: " + list); 57 58 list = nc.ip6MulticastInterfaces() 59 .map(NetworkInterface::getName) 60 .collect(joining(" ")); 61 out.println("ip6MulticastInterfaces: " + list); 62 63 list = nc.ip6Addresses() 64 .map(Inet6Address::toString) 65 .collect(joining(" ")); 66 out.println("ip6Addresses: " + list); 67 } 68 }