Created
October 14, 2012 13:33
-
-
Save kappa7194/3888602 to your computer and use it in GitHub Desktop.
Memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package it.penpen.android.passphrase_generator; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.List; | |
import android.content.Context; | |
import android.os.AsyncTask; | |
public class DictionaryLoaderAsyncTask extends AsyncTask<Context, Integer, List<String>> { | |
@Override | |
protected List<String> doInBackground(Context... params) { | |
String word; | |
List<String> dictionary = new ArrayList<String>(); | |
InputStream inputStream = params[0].getResources().openRawResource(R.raw.dictionary); // TODO: This feels dirty. | |
InputStreamReader inputReader = new InputStreamReader(inputStream); | |
BufferedReader bufferedReader = new BufferedReader(inputReader); | |
try { | |
while ((word = bufferedReader.readLine()) != null) { | |
dictionary.add(word); | |
} | |
} catch (IOException e) { | |
return null; | |
} | |
return dictionary; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment