Skip to content

Instantly share code, notes, and snippets.

@rayworks
Last active June 8, 2016 04:04
Show Gist options
  • Save rayworks/6c37a3f197e8c88a6b4370545955df25 to your computer and use it in GitHub Desktop.
Save rayworks/6c37a3f197e8c88a6b4370545955df25 to your computer and use it in GitHub Desktop.
Read lines from file in folder asserts
public static List<String> readLinesFromAssetFile(String fileName, final Context context) throws IOException {
InputStream inputStream = context.getAssets().open(fileName);
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
LineReader lr = new LineReader(br);// from Guava
List<String> lines = new LinkedList<>();
String line;
while ((line = lr.readLine()) != null){
lines.add(line);
}
try {
br.close();
} catch (IOException e) {
/** ignored **/
}
return lines;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment