随笔 - 6  文章 - 129  trackbacks - 0
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(14)

随笔档案(6)

文章分类(467)

文章档案(423)

相册

收藏夹(18)

JAVA

搜索

  •  

积分与排名

  • 积分 - 814928
  • 排名 - 49

最新评论

阅读排行榜

评论排行榜

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 阅读(639) 评论(0)  编辑  收藏 所属分类: java

只有注册用户登录后才能发表评论。


网站导航: