i had this in my class: private Context mCtx = getBaseContext();
then the following code is my other class from which i want to use a file dictionary.txt
from assets folder, I get IO Exception
. Please Help
public class RandomStringGenerator {
private final char[] generatedLetters = generate4().toCharArray();
private int formedWordNo = 0;
private final Set <String> formedWords = wordDictAvail(generatedLetters.toString());
public Set<String> wordDictAvail (String inword){
Set<String> set = new HashSet<String>();
int wa = 0;
int dictWordLn;
String dictWord;
try {
is =mCtx.getAssets().open("dictionary.txt");
Scanner scanner=new Scanner("is");
while (scanner.hasNextLine()) {
String currChar;
int i = 1;
dictWord = scanner.nextLine().trim();
dictWordLn = dictWord.length();
for (int a = 0; a <= dictWordLn-1 ; a++){
currChar = Character.toString(dictWord.charAt(a));
if (inword.contains(currChar)){
i =i*1;
} else {i=i*2;}
}
if (i==1){
set.add(dictWord);
wa++;
}
}
scanner.close();
} catch(IOException e) {
e.printStackTrace();
}
}