Essays24.com - Term Papers and Free Essays
Search

Poof

Essay by   •  November 17, 2010  •  567 Words (3 Pages)  •  1,069 Views

Essay Preview: Poof

Report this essay
Page 1 of 3

awesome.../*

* Main.java

*

* Created on May 10, 2007, 6:48 PM

*

* To change this template, choose Tools | Template Manager

* and open the template in the editor.

*/

package crossword;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.ArrayList;

import java.io.BufferedReader;

import java.io.FileReader;

/**

*

* @author Chris

*/

public class Main

{

/** Creates a new instance of Main */

public Main()

{

}

/**

* @param args the command line arguments

*/

static ArrayList input = new ArrayList(1);

static ArrayList words = new ArrayList(1);

public static void main(String[] args)

{

// begin creating file reader

String path = "C:\Documents and Settings\Conner\Desktop\crossword\words.txt";

FileReader fileReader;

try{

fileReader = new FileReader(path);

}

catch(FileNotFoundException ex){

System.out.println("File not found: " + path);

System.out.println(ex.getMessage());

return;

}catch(IOException ex){

System.out.println("Exception caught");

System.out.println(ex.getMessage());

return;

}

BufferedReader bufferedReader = new BufferedReader(fileReader);

//use filereader to read word list into String ArrayList input

try{

String newLine = new String();

boolean firstTime = true;

do{

newLine = bufferedReader.readLine();

if(newLine != null){

input.add(newLine);

}

}while(newLine != null);

bufferedReader.close();

fileReader.close();

}catch(IOException ex){

System.out.println("Read error. Process aborted.");

System.out.println(ex.getMessage());

return;

}

fileReader = null; //fileReader is no longer useful

//feed input into Word ArrayList words

Word temp;

while(!input.isEmpty()){

temp = new Word(input.remove(input.size() - 1));

words.add(temp);

}

input.clear();

InputStreamReader in = new InputStreamReader(System.in);

bufferedReader = new BufferedReader(in);

String term = null;

do{

try

{

term = readTerm(bufferedReader);

ArrayList results = new ArrayList();

if(term != null && !words.isEmpty()){

results = search(words, term);

}

System.out.println("matches found: " + results.size());

if(!results.isEmpty()){

for(int i = 0; i <

...

...

Download as:   txt (4.1 Kb)   pdf (74.9 Kb)   docx (10.4 Kb)  
Continue for 2 more pages »
Only available on Essays24.com