import java.io.*; class GetEmailAddresses { public static void main(String[] args) throws Exception { if (args.length < 1) { System.out.println("Usage: java GetEmailAddresses searchSite"); System.out.println("Example: java GetEmailAddresses http://community-info.org"); System.out.println("The searchSite is where the search starts, but can wind up anywhere on the Internet."); System.exit(0); } //define a string for assigning to addresses to. //open up file that stores to addresses FileInputStream fstream = new FileInputStream("people.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String to_addr = null; String CLStr = "Java SearchCrawler"; String searchSite = args[0]; File synchronicity = new File("IAmRunning"); while ((to_addr = br.readLine()) != null) { System.out.println("Check to see if SearchCrawler is already running or not\n"); while (synchronicity.exists()) { System.out.println("SearchCrawler is already running, wait a minute\n"); try { Thread.sleep(60000); // check once a minute } catch (InterruptedException ie) { System.out.println(ie.getMessage()); } } if (!(synchronicity.exists())) { System.out.println("Call SearchCrawler: "); String CLArg = CLStr + " " + '\"' + to_addr + '\"' + " " + searchSite; System.out.println(CLArg + "\n"); Process myProcess = Runtime.getRuntime().exec(CLArg); System.out.println("Just made call\n"); try { Thread.sleep(60000); // wait a minute } catch (InterruptedException ie) { System.out.println(ie.getMessage()); } } } } }