All pastes #257922 Raw Edit

Unnamed

public text v1 · immutable
#257922 ·published 2006-11-25 23:05 UTC
rendered paste body
/*
 * Main.java
 *
 * Created on 22. November 2006, 15:04
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package javaapplication5;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Frame;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.regex.Matcher;
import javax.swing.JApplet;
import javax.swing.JTextArea;



/**
 *
 * @author kj09
 */
public class Main extends Applet  {
    
      
    /** Creates a new instance of Main */
    public void init(){
        System.out.println("Welcome.");
        System.out.println("Starting up...");
        //0. Interface erzeugen:
        System.out.println("..Building User Interface..");
        JTextArea text = new JTextArea();
        text.setEditable(false);
        text.setBackground(new Color(255, 255, 255));
        text.setForeground(new Color(0, 0,0 ));
        this.add(text);
        this.validate();
        
        System.out.println("..Creating Storage Device..");
        try {
         final Storage stor = new Storage("C:/Serienbrief_Adressen.xls", "data");
        
    
            ThreadGroup crawlers = new ThreadGroup("crawlers");
        

        System.out.println("Done");
        //2. Initialisieren des Pools:
        Collection initvals = new ArrayList();
        System.out.println("..Initializing URL-Pool..");
        final Workpool p = new Workpool(crawlers);
        System.out.println("Done");
        System.out.println("..Generating inital-URLs..");
        int i = 0;
       for( i=192089; i<192096; i++){
            
            URLentry addentry = new URLentry("http://www.bildungsportal.nrw.de/BP/_suche1/SchuleSuchen/schule_info.php?SNR="+i);
            
           p.add(addentry);
       }
        System.out.println("Done");
        //OK, nun kann die Arbeit beginnen.
        //Main-Schleife initialisieren:
        System.out.println("..Starting main-process..");
        
        for(int z=0; z<10; z++){ //10 Crawler erstellen:
         new Thread(crawlers, new Crawler(p, stor)).start();
        }
        

        } catch (IOException ex) {
            System.out.println("Cannot create Storage."); 
            ex.printStackTrace();
        }
        
        }
        
        public void finish(){
     
    
            System.out.println("Done.");
            

        System.out.println("*Finished*");          
  
        }
           
   }