I seem to be able to load the files in my program. Then I can loop through the lines one time, but if I try a second loop to load the strings into an array that one won't work.
Here's my code. I thank you for any help in advance.
EDIT: Its the 4th while loop that isn't working. The first three are fine.
import java.net.URL;
import java.io.*;
public class SpellChecker{
BufferedReader words = null;
BufferedReader newList = null;
BufferedReader customWords = null;
BufferedReader customNewList = null;
File cust = new File("customWords.txt");
String line = " ";
String[] spellList;
String[] custList;
String displayLine;
int i = 0;
int j = 0;
public SpellChecker(){
try{
URL url = new URL("edited for privacy");
words = new BufferedReader( new InputStreamReader(url.openStream()));
newList = new BufferedReader( new InputStreamReader(url.openStream()));
FileInputStream file = new FileInputStream(cust);
customWords = new BufferedReader( new InputStreamReader(file));
customNewList = new BufferedReader( new InputStreamReader(file));
while((line = words.readLine()) != null){
i++;
}
spellList = new String [i+1];
i = 0;
while((line = newList.readLine()) != null ){
spellList[i] = line;
//System.out.println(line);
i++;
}
while((line = customWords.readLine()) != null){
j++;
}
System.out.println("Loading custom list array");
custList = new String [j+1];
j = 0;
while((line = customNewList.readLine()) != null){
System.out.println("Array loaded");
custList[j] = line;
System.out.println(line);
j++;
}
}
catch(Exception e){
System.err.print(e);
}
finally{
try{
words.close();
}
catch(Exception e){
System.err.print(e);
}
}
}//end constructor