1
1
/*
2
- * Copyright (c) 2015, 2018 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,9 @@ public class getOriginalHostName {
41
41
public static void main (String [] args ) throws Exception {
42
42
final String HOST = "dummyserver.java.net" ;
43
43
InetAddress ia = null ;
44
- ia = InetAddress .getByName (HOST );
44
+ ia = getInetAddress (HOST );
45
+ if (ia != null ) testInetAddress (ia , HOST );
46
+ ia = InetAddress .getByAddress (HOST , new byte [] { 1 , 2 , 3 , 4 });
45
47
testInetAddress (ia , HOST );
46
48
ia = InetAddress .getByName ("255.255.255.0" );
47
49
testInetAddress (ia , null );
@@ -53,6 +55,14 @@ public static void main(String[] args) throws Exception {
53
55
testInetAddress (ia , ia .getHostName ());
54
56
}
55
57
58
+ private static InetAddress getInetAddress (String host ) {
59
+ try {
60
+ return InetAddress .getByName (host );
61
+ } catch (java .net .UnknownHostException uhe ) {
62
+ System .out .println ("Skipping " + host + " due to " + uhe );
63
+ return null ;
64
+ }
65
+ }
56
66
57
67
private static void testInetAddress (InetAddress ia , String expected )
58
68
throws Exception {
0 commit comments