2.
privatejava.util.Timertimer=null;
publicvoidcontextInitialized(ServletContextEventevent){
timer=newjava.util.Timer(true);
event.getServletContext().log("定时器已启动");
timer.schedule(newMyTask(event.getServletContext()),0,60*60*1000);
event.getServletContext().log("已经添加任务调度表");
}
publicvoidcontextDestroyed(ServletContextEventevent){
timer.cancel();
event.getServletContext().log("定时器销毁");
}
3.
int data;//从输入流中获取数据
URL url=new URL("http://www.sohu.com");
//创建连接的地址
HttpURLConnection connection=url.openConnection();
//打开连接
int responsCode=connection. getResponseCode();
//返回Http的响应状态码
InputStream input=connection.getInputStream();
//获取输入流
System.out.println("responseCode:"+responseCode);
While((data=input.read())!=-1)
System.out.println(data);
//将获取的数据打到屏幕显示出来
privatejava.util.Timertimer=null;
publicvoidcontextInitialized(ServletContextEventevent){
timer=newjava.util.Timer(true);
event.getServletContext().log("定时器已启动");
timer.schedule(newMyTask(event.getServletContext()),0,60*60*1000);
event.getServletContext().log("已经添加任务调度表");
}
publicvoidcontextDestroyed(ServletContextEventevent){
timer.cancel();
event.getServletContext().log("定时器销毁");
}
3.
int data;//从输入流中获取数据
URL url=new URL("http://www.sohu.com");
//创建连接的地址
HttpURLConnection connection=url.openConnection();
//打开连接
int responsCode=connection. getResponseCode();
//返回Http的响应状态码
InputStream input=connection.getInputStream();
//获取输入流
System.out.println("responseCode:"+responseCode);
While((data=input.read())!=-1)
System.out.println(data);
//将获取的数据打到屏幕显示出来
解决方案 »
- 关于spring配置Quartz定时任务超时的问题
- javascript小问题
- tomcat问题
- .net ? .net? 求解!
- 客户更新我给的.class后,登录出错,提示是找不到这个类
- 关于FCKeditor编辑html,如何将其应用于网站之中
- java集成BO 出现的问题
- 有酬求购一个Struts网站的源代码
- log4j 没有按照设置configuration来记录日志信息 郁闷! 谁来解决。。。。
- 十万火急!不懂WebService但公司要我马上上手!请高手介绍几本容易上手的书!学过EJB
- j2ee开发,数据库要学到什么程度呢
- 一道面试题,大家看看这个内部类如何去实例化。。。。。。。。。。。。。
效率比较低的说,有好的方法的朋友请出招