16
16
import java .nio .file .Files ;
17
17
import java .nio .file .StandardCopyOption ;
18
18
import java .util .Arrays ;
19
+ import java .util .Collections ;
19
20
import java .util .List ;
20
21
import java .util .function .Function ;
21
22
import java .util .stream .Collectors ;
@@ -257,12 +258,12 @@ private static URLConnection getConnection(String address) {
257
258
return connection ;
258
259
} catch (SSLHandshakeException e ) {
259
260
System .out .println ("Failed to establish connection to " + address );
260
- System .out .println (" Host: " + url .getHost () + " [" + getIps (url .getHost ()). stream (). collect ( Collectors . joining ( ", " )) + "]" );
261
+ System .out .println (" Host: " + url .getHost () + " [" + getIpString (url .getHost ()) + "]" );
261
262
e .printStackTrace ();
262
263
return null ;
263
264
} catch (IOException e ) {
264
265
System .out .println ("Failed to establish connection to " + address );
265
- System .out .println (" Host: " + url .getHost () + " [" + getIps (url .getHost ()). stream (). collect ( Collectors . joining ( ", " )) + "]" );
266
+ System .out .println (" Host: " + url .getHost () + " [" + getIpString (url .getHost ()) + "]" );
266
267
e .printStackTrace ();
267
268
return null ;
268
269
}
@@ -273,9 +274,12 @@ public static List<String> getIps(String host) {
273
274
InetAddress [] addresses = InetAddress .getAllByName (host );
274
275
return Arrays .stream (addresses ).map (InetAddress ::getHostAddress ).collect (Collectors .toList ());
275
276
} catch (UnknownHostException e1 ) {
276
- e1 . printStackTrace ( );
277
+ return Arrays . asList ( "Unknown" );
277
278
}
278
- return null ;
279
+ }
280
+
281
+ public static String getIpString (String host ) {
282
+ return getIps (host ).stream ().collect (Collectors .joining (", " ));
279
283
}
280
284
281
285
public static boolean checkCertificate (String host ) {
0 commit comments