package SFIS.DB;
import java.net.MalformedURLException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class URLConnectionTest {
public static void main(String []args){
try {
long begintime = System.currentTimeMillis();
URL url = new URL("http://10.240.19.112:8080/quartz/jobs/executeJob.action?jobName=NOTEPAD_JOB&jobGroup=DEFAULT");
HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
System.out.println(urlcon.getResponseCode());
urlcon.connect();
//InputStream is = urlcon.getInputStream();
/*InputStream is = urlcon.getErrorStream();
if(null != is) {
BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
StringBuffer bs = new StringBuffer();
String l = null;
while((l=buffer.readLine())!=null){
bs.append(l).append("\n");
}
System.out.println(bs.toString());
is.close();
} else if (null == is) {
System.out.println("Null");
} else {
System.out.println("UNKNOW...");
}*/
//System.out.println(" content-encode:"+urlcon.getContentEncoding());
//System.out.println(" content-length:"+urlcon.getContentLength());
//System.out.println(" content-type:"+urlcon.getContentType());
//System.out.println(" date:"+urlcon.getDate());
System.out.println("total time:"+(System.currentTimeMillis()-begintime)+"毫秒");
urlcon.disconnect();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
posted on 2009-03-20 13:49
Ke 阅读(648)
评论(0) 编辑 收藏 所属分类:
java