File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public static void tryRemote(InetSocketAddress remote) {
39
39
System .out .println ("local: " + local );
40
40
NetworkInterface ni = NetworkInterface .getByInetAddress (local );
41
41
System .out .println ("interface: " + ni );
42
- System .out .println ("hardware: " + (ni == null ? null : ni .getHardwareAddress (). toString (). substring ( 3 )));
42
+ System .out .println ("hardware: " + (ni == null ? null : macBytesToHex ( ni .getHardwareAddress ())));
43
43
} catch (Throwable t ) {
44
44
System .out .println (t );
45
45
t .printStackTrace ();
@@ -49,4 +49,12 @@ public static void tryRemote(InetSocketAddress remote) {
49
49
}
50
50
}
51
51
}
52
+
53
+ public static String macBytesToHex (byte [] bytes ) {
54
+ StringBuilder sb = new StringBuilder ();
55
+ for (int i = 0 ; i < bytes .length ; i ++) {
56
+ sb .append (String .format ("%02X%s" , bytes [i ], (i < bytes .length - 1 ) ? "-" : "" ));
57
+ }
58
+ return sb .toString ();
59
+ }
52
60
}
You can’t perform that action at this time.
0 commit comments