ITeye博客

jdbc网络断开-检测网络连接状态

ayanline · 2011-08-30 01:33 · JDBC · 开源软件 · Markdown


public static void main(String[] args) {   
        URL url = null;   
        try {   
            url = new URL("http://baidu.com");   
            try {   
                InputStream in = url.openStream();   
                in.close();   
                System.out.println("网络连接正常!");   
            } catch (IOException e) {   
                System.out.println("网络连接失败!");   
            }   
        } catch (MalformedURLException e) {   
            e.printStackTrace();   
        }   
    }  

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。