I'm currently trying to create a very basic job scheduler. I'm trying to create an app that will check the current local system time. If the time is 12 am, it will download from a link "http://javadl.sun.com/webapps/download/AutoDL?BundleId=58134" to my desktop. Does anyone has a clue to do this with Java? Currently, I'm only able to check current local system time.
package task;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.io.*;
import java.net.URL;
class MyTask extends TimerTask {
public static void main(String[] args) {
Timer timer = new Timer();
timer.schedule(new MyTask(), 60 * 1000);
public void run() {
Date date = new Date();
if(date.compareTo(midnight) == 0) {
//Download code
URL google = new URL("http://www.google.it");
ReadableByteChannel rbc = Channels.newChannel(google.openStream());
FileOutputStream fos = new FileOutputStream("google.html");
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
}
}
}
}