I have a problem reading a txt file quickly in an ArrayList. If I want to read a file size of 0.9 MB, I have to wait 5 minutes. If the file size is 34 MB (in part because the android does not accept files larger than 1 MB), it does not work completely. I think the process should be max a few seconds.
This is the code:
String word;
public ArrayList<String> dictionary = new ArrayList<String>();
public void setup()
{
try {
AssetManager assetManager = getAssets();
InputStream inputf;
inputf = assetManager.open("dict_1.txt");
reader = new BufferedReader(new InputStreamReader(inputf));
word = " ";
while(word != null)
{
word = reader.readLine();
if (word != null)
dictionary.add(word);
}
if(reader.equals("null")) println("No file found");
} catch (NullPointerException e) {
e.printStackTrace();
println("No file found");
} catch (IOException e) {
e.printStackTrace();
}
}
Sorry for my english. I hope everything will be understated.
source
share