package org.act.domain;import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;/*****************
* 测试网站是否关闭
* @author shenkunlin
* date 2013/8/13
*/
public class HttpTest { public int httpURL(String path){
int status=404;
try {
URL url =new URL(path);
HttpURLConnection con=null;
con=(HttpURLConnection) url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
//请求响应状态:200成功
status = con.getResponseCode();
} catch (MalformedURLException e) {
System.out.println("创建URL实例失败.");
} catch (IOException e) {
System.out.println("请求发生异常.");
}
return status;
}
public static void main(String[] args) {
HttpTest df =new HttpTest();
int status = df.httpURL("http://www.googdsfsdle.com");
System.out.println(status);
}
}
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;/*****************
* 测试网站是否关闭
* @author shenkunlin
* date 2013/8/13
*/
public class HttpTest { public int httpURL(String path){
int status=404;
try {
URL url =new URL(path);
HttpURLConnection con=null;
con=(HttpURLConnection) url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
//请求响应状态:200成功
status = con.getResponseCode();
} catch (MalformedURLException e) {
System.out.println("创建URL实例失败.");
} catch (IOException e) {
System.out.println("请求发生异常.");
}
return status;
}
public static void main(String[] args) {
HttpTest df =new HttpTest();
int status = df.httpURL("http://www.googdsfsdle.com");
System.out.println(status);
}
}