View Single Post
Old 05-1-2012, 07:07 AM   #19
UserNameGoesHere
FFR Veteran
FFR Veteran
 
UserNameGoesHere's Avatar
 
Join Date: May 2008
Posts: 1,114
Send a message via AIM to UserNameGoesHere
Default Re: [JAVA] Site Search Help

Code:
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;

public class URLReader{
	public static void main(String[] args) throws Exception{
		URLReader a = new URLReader();
	}
	
	public URLReader() throws Exception{
		URL site = new URL("http://kaction.com/badfanfiction/");
		BufferedReader in = new BufferedReader(
				new InputStreamReader(site.openStream()));
		BufferedWriter out = new BufferedWriter(
				new OutputStreamWriter(
				new FileOutputStream("savedsite.html")));
		
		String inputLine;
		boolean found = false;
		while((inputLine = in.readLine()) != null){
			out.write(inputLine, 0, inputLine.length());
			if(inputLine.contains("the")){
				if(!found){
					System.out.println(inputLine);
					found = true;
				}
			}
		}
		out.close();
		if(found){
			Runtime.getRuntime().exec("firefox -new-tab savedsite.html");
		}
		else{
			Thread.sleep(2000);
			Thread.sleep(2000);
			in.close();
			URLReader b = new URLReader();
		}
	}
}
Does this do what you want?
__________________
Quote:
Originally Posted by Crashfan3 View Post
Man, what would we do without bored rednecks?
[SIGPIC][/SIGPIC]

Last edited by UserNameGoesHere; 05-1-2012 at 07:15 AM..
UserNameGoesHere is offline   Reply With Quote