Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/net/NetworkConfigurationProbe.java
41145 views
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
* @build jdk.test.lib.NetworkConfiguration
29
* jdk.test.lib.Utils
30
* jdk.test.lib.Asserts
31
* jdk.test.lib.JDKToolFinder
32
* jdk.test.lib.JDKToolLauncher
33
* jdk.test.lib.Platform
34
* jdk.test.lib.process.*
35
* @run main NetworkConfigurationProbe
36
*/
37
38
import java.net.Inet4Address;
39
import java.net.Inet6Address;
40
import java.net.NetworkInterface;
41
import jdk.test.lib.NetworkConfiguration;
42
import static java.util.stream.Collectors.joining;
43
import static java.lang.System.out;
44
45
/**
46
* Not a test. Captures the network interface configuration.
47
*/
48
public class NetworkConfigurationProbe {
49
50
public static void main(String... args) throws Exception {
51
NetworkConfiguration.printSystemConfiguration(out);
52
53
NetworkConfiguration nc = NetworkConfiguration.probe();
54
String list;
55
list = nc.ip4MulticastInterfaces()
56
.map(NetworkInterface::getName)
57
.collect(joining(" "));
58
out.println("ip4MulticastInterfaces: " + list);
59
60
list = nc.ip4Addresses()
61
.map(Inet4Address::toString)
62
.collect(joining(" "));
63
out.println("ip4Addresses: " + list);
64
65
list = nc.ip6MulticastInterfaces()
66
.map(NetworkInterface::getName)
67
.collect(joining(" "));
68
out.println("ip6MulticastInterfaces: " + list);
69
70
list = nc.ip6Addresses()
71
.map(Inet6Address::toString)
72
.collect(joining(" "));
73
out.println("ip6Addresses: " + list);
74
}
75
}
76
77