1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
public class Repeter {
/**
* @param args the command line arguments
*/
Timer t;
public Repeter() {
t = new Timer();
t.schedule(new MonAction(), 0, 1 * 1000);
}
class MonAction extends TimerTask {
int nbrRepetitions = 3;
public void run() {
if (nbrRepetitions > 0) {
//System.out.println("Ca bosse dur!");
try {
URL url = new URL("Chaine de l'URL de la page php");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.connect();
} catch (Exception e) {
System.out.println("Echec d'execution du programme.");
}
nbrRepetitions--;
} else {
//System.out.println("Terminé!");
t.cancel();
}
}
}
public static void main(String[] args) throws Exception {
// TODO code application logic here
new Repeter();
}
} |
Partager