Android Java - reading dictionary assets -


this might duplicated thread after trying out several , multiple threads problem still continues :/

i have method reads dictionary , decryption . , have no idea how read dictionary . drag , dropped dictionary assets folder , used code .

    try {         system.out.println("dictionary initialize");         bufferedreader inputreader;         fileinputstream fis = new fileinputstream("/assets/dictionary-english.txt");         bufferedreader dictionary = new bufferedreader(new inputstreamreader(fis));         string checktext;          while ((checktext = dictionary.readline()) != null) {             dictionaryset.add(checktext);         }         system.out.println("dictionary initialized");      } catch (ioexception ex) {         system.out.println("error! reading!");     } 

after several test , have confirmed not reach while loop try , catch catches error . caught ioexception error . idea how fix ? thanks

this error log cat

               10-06 14:54:50.555: w/system.err(1980): java.io.filenotfoundexception: /assets/dictionary-english.txt (no such file or directory)                 10-06 14:54:50.555: w/system.err(1980):     @ org.apache.harmony.luni.platform.osfilesystem.open(native method)                 10-06 14:54:50.555: w/system.err(1980):     @ dalvik.system.blockguard$wrappedfilesystem.open(blockguard.java:232)                  10-06 14:54:50.555: w/system.err(1980):    @ java.io.fileinputstream.<init>(fileinputstream.java:80)                   10-06 14:54:50.565: w/system.err(1980):   @ java.io.fileinputstream.<init>(fileinputstream.java:132) 

edited: tried using
assetmanager assetmanager = getassets();

however error on getassets() "cannot make static reference non-static method getassets() type contextwrapper "

========================================================================

answer: bufferedreader dictionary = new bufferedreader(new inputstreamreader(getassets().open("dictionary-english")));

i used line of code file , in method removed static solved cannot make static reference problem

         eg;   private static string run1(string ciphertext){  --> private string run1(string ciphertext){ 


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -