Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package fisica.cerca.compito;
- import java.awt.Toolkit;
- import java.io.IOException;
- import java.net.HttpURLConnection;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.concurrent.TimeUnit;
- /**
- *
- * @author Nikola
- */
- public class FisicaCercaCompito
- {
- public static void main(String[] args) throws MalformedURLException, IOException, InterruptedException
- {
- // compito23_2_10.pdf
- // problema15-7-11new.pdf
- // compito_22_06_12.pdf
- String[] A = {"compito", "problema"/*,"compitonew","problemanew"*/};
- String[] B = {"", "_", "-"};
- String[] C = {"20"};
- String[] D = {"-", "_"};
- String[] E = {"07", "7"};
- String[] F = {"-", "_"};
- String[] G = {"12", "2012"};
- String[] H = {/*"new",*/ ""};
- String nome;
- ArrayList<String> possibiliNomi = new ArrayList(0);
- for(String iA : A)
- {
- for(String iB : B)
- {
- for(String iC : C)
- {
- for(String iD : D)
- {
- for(String iE : E)
- {
- for(String iF : F)
- {
- for(String iG : G)
- {
- for(String iH : H)
- {
- nome = iA + iB + iC + iD + iE + iF + iG + iH + ".pdf";
- possibiliNomi.add(nome);
- }
- }
- }
- }
- }
- }
- }
- }
- System.out.println("Generati " + possibiliNomi.size() + " nomi");
- int numeroCicli=1;
- int nomiCorrenti=1;
- URL url;
- HttpURLConnection http;
- //while(true)
- {
- nomiCorrenti = 1;
- for(String nomeCorrente : possibiliNomi)
- {
- url = new URL("http://webcen.di.unimi.it/wcinfo/pages/74707/" + nomeCorrente);
- System.out.print("Ciclo " + numeroCicli + ": " + (nomiCorrenti++) + "/" + possibiliNomi.size() + ") " + String.format("%-25s:", nomeCorrente) + " ");
- http = (HttpURLConnection) url.openConnection();
- if(http.getResponseCode() == 404)
- {
- System.out.println("NEGATIVO");
- }
- else
- {
- System.out.println("TROVATO");
- System.out.println("");
- System.out.println("");
- System.out.println(url.toString());
- System.out.println("");
- System.out.println("");
- beep();
- }
- TimeUnit.MILLISECONDS.sleep(500);
- }
- numeroCicli++;
- }
- }
- private static void beep() throws InterruptedException
- {
- while(true)
- {
- Toolkit.getDefaultToolkit().beep();
- TimeUnit.MILLISECONDS.sleep(500);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement