package com.slowlybirld.ui;
import java.io.*;
import java.net.URL;
public class 网络连接模块
{
public static void main(String[] args) {
URL url = null;
try {
url = new URL( "http://baidu.com/");
InputStream in = url.openStream();
System.out.println( "Internet正常 ");
in.close();
} catch (IOException e) {
System.out.println( "无法连接到: Internet");
}
}
}
转载于:https://my.oschina.net/jgy/blog/24392