public class getyininfo extends timertask {
private void getcomexinfo() throws ioexception{
string res = "";
simpledateformat dateformat=new simpledateformat("hh:mm:ss");
string df=dateformat.format(new date());
url url = new url("//www.jb51.neti");
java.net.httpurlconnection conn = (java.net.httpurlconnection) url.openconnection();
conn.connect();
bufferedreader bf = new bufferedreader(new inputstreamreader(
conn.getinputstream(), "gbk"));
string line;
while ((line = bf.readline()) != null) {
res += line;
}
string agtd[]=res.split(",");
string re[]=agtd[0].split(""");
system.out.println("comex "+df+":"+re[1]);
bf.close();
}
private void gettdinfo() throws ioexception{
string res = "";
simpledateformat dateformat=new simpledateformat("hh:mm:ss");
string df=dateformat.format(new date());
url url = new url(//www.jb51.net);
java.net.httpurlconnection conn = (java.net.httpurlconnection) url.openconnection();
conn.connect();
bufferedreader bf = new bufferedreader(new inputstreamreader(
conn.getinputstream(), "gbk"));
string line;
while ((line = bf.readline()) != null) {
res += line;
}
string agtd[]=res.split(",");
string re[]=agtd[0].split(""");
system.out.println("ag "+df+":"+re[1]);
bf.close();
}
@override
public void run() {
try {
getcomexinfo();
gettdinfo();
system.out.println("---------------------------------------------");
} catch (ioexception e) {
e.printstacktrace();
}
}
/**
* @param args
*/
public static void main(string[] args) {
timer timer = new timer();
timertask t1 = new getyininfo();
//1000毫秒后,每隔1000毫秒运行一次t1任务
timer.schedule(t1,1000,5000);
/*try {
thread.sleep(10000);
} catch (interruptedexception e) {
e.printstacktrace();
}
timer.cancel();*/
}
}
如对本文有疑问, 点击进行留言回复!!
SpringBoot引用阿里easyexcel,Excel导出返回浏览器下载
HashMap、Hashtable、ConcurrentHashMap三者间的异同
解决RecycleView 中Item包含Edittext时,滑动view复用导致数据错乱的问题
多线程、同步工作原理、死锁案例、Lock接口、线程的生命周期的讲解及实现
网友评论