📄 checknetwork.java
字号:
import java.net.InetAddress;import java.net.UnknownHostException;import java.io.IOException;public class CheckNetwork{ public static boolean checkLocalHost() { try { InetAddress.getLocalHost(); return true; } catch (UnknownHostException e) { } catch (IOException e) { } return false; } public static boolean checkRemote() { String host1 = "api.efxnow.com"; String host2 = "www.google.com"; boolean connected = true; try { InetAddress.getByName(host1); return true; } catch (UnknownHostException e) { } catch (Exception e) { } try { InetAddress.getByName(host2); return true; } catch (UnknownHostException e) { } catch (Exception e) { } return false; } public static void main(String[] a) { System.out.println("local:"+checkLocalHost()); System.out.println("remote:"+checkRemote()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -