复制代码代码如下:
impor java.io.BufferedReader;
impor java.io.IOException;
impor java.io.InputStreamReader;
impor java.net.URL;
impor java.teks.SimpleDateFormat;
import java.util.Date;
impor java.util.Timer;
impor java.util.TimerTask;
kelas publik GetYinInfo memperluas TimerTask {
private void getCOMEXInfo() melempar IOException{
String res = "";
SimpleDateFormat format tanggal=new SimpleDateFormat("HH:mm:ss");
String df=format tanggal.format(Tanggal baru());
URL url = URL baru("//www.VeVB.COmI");
java.net.HttpURLConnection samb = (java.net.HttpURLConnection) url.openConnection();
samb.connect();
BufferedReader bf = BufferedReader baru(InputStreamReader baru(
samb.getInputStream(), "GBK"));
garis senar;
while ((baris = bf.readLine()) != null) {
res += baris;
}
String AGTD[]=res.split(",");
String ulang[]=AGTD[0].split(""");
System.out.println("COMEX "+df+":"+re[1]);
bf.dekat();
}
private void getTDInfo() melempar IOException{
String res = "";
SimpleDateFormat format tanggal=new SimpleDateFormat("HH:mm:ss");
String df=format tanggal.format(Tanggal baru());
URL url = URL baru(//www.VeVB.COM);
java.net.HttpURLConnection samb = (java.net.HttpURLConnection) url.openConnection();
samb.connect();
BufferedReader bf = BufferedReader baru(InputStreamReader baru(
samb.getInputStream(), "GBK"));
garis senar;
while ((baris = bf.readLine()) != null) {
res += baris;
}
String AGTD[]=res.split(",");
String ulang[]=AGTD[0].split(""");
System.out.println("AG "+df+":"+re[1]);
bf.dekat();
}
@Mengesampingkan
menjalankan kekosongan publik() {
mencoba {
dapatkanCOMEXInfo();
dapatkanTDInfo();
Sistem.keluar.println("------------------------------------------- --");
} tangkapan (IOException e) {
e.printStackTrace();
}
}
/**
* @param argumen
*/
public static void main(String[] args) {
Pengatur waktu = Pengatur Waktu baru();
TimerTask t1 = GetYinInfo baru();
//1000 poin, 1000 poin, 1000 poin
timer.jadwal(t1,1000,5000);
/*mencoba {
Thread.tidur(10000);
} tangkapan (InterruptedException e) {
e.printStackTrace();
}
pengatur waktu.batal();*/
}
}