package com.sharp.url;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import javax.management.RuntimeErrorException;
/**
* Hello world!
*
*/
public class App
{
public static void main(String[] args) {
try {
new App().connection();
} catch (Exception e) {
System.out.println("出异常了"+e.getMessage());
}
System.out.println("完成");
}
public void connection()
{
try {
URL url = new URL("http://www.hello.com");
URLConnection conn = url.openConnection();
conn.setReadTimeout(1000);
conn.setConnectTimeout(1000);
conn.connect();
} catch (Exception e) {
throw new RuntimeException("客户端连接不上");
}
}
}
URL url = new URL("http://172.16.3.195:9999/ESB/services/IHomeFlightBaseWsService?wsdl");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setReadTimeout(1000);
conn.setConnectTimeout(1000);
if(200 != conn.getResponseCode()){
throw new RuntimeException("连接异常");
}