Hey guys, would like to thank everyne for help on previous post.
the following code is meant to populate a hashmap and hash set respectivly, but when i run my programme its giving me a null pointer in my user interface, could anyone help guide me?
package concordanceReader;
import java.util.*;
import java.io.*;
public class newTEST {
private static Set<String> byWord; // maps word with sentence
private static Map<String,Set<String>> bySentence;// maps sentence with text
//loads all the text files into java
private static String[] fileList = { "
"C:/Documents and Settings/1.txt",
"C:/Documents and Settings/2.txt",
"C:/Documents and Settings/1.txt",
"C:/Documents and Settings/4.txt",
public newTEST()
{
bySentence = new HashMap<String,Set<String>>();
byWord = new HashSet<String>();
}
public static void populateSet() throws Exception{
for (String filename : fileList){
Scanner scanner = new Scanner(new File(filename));
while (scanner.hasNext())
{
String word = scanner.next();
byWord.add(word);
}
}
}
public static Map<String, Set<String>> populateMap() throws Exception{
for (String filename : fileList){
Scanner scanner = new Scanner(new File(filename));
while (scanner.hasNextLine()) {
populateSet();
String sentence = scanner.nextLine();
bySentence.put(sentence, byWord);
}
}
return bySentence;
}
}