This is my method for getting the .txt file inside a .java class
public static void find() throws IOException
{
@SuppressWarnings("resource")
Scanner sc = new Scanner(new FileReader("AllWords.txt"));
while( sc.hasNextLine() )
{
String word = sc.nextLine();
words.add(word);
String sortedWord = sortString(word); // this is a key
ArrayList<String> anagrams = map.get( sortedWord ); //this is a value
if( anagrams == null ) anagrams = new ArrayList<String>();
anagrams.add(word);
map.put(sortedWord, anagrams);
}
}
-When I call find() inside an Activity class it wont read the .txt file, but I have tested this code in another program and it opens the file, but since I moved to Android - development I haven't been able to read this file.
-I have also tried to create this method inside an Activity class and android environment does not like "SortString".
-Could the problem be the location of my .txt file?
Here is the location: