Last active
June 8, 2016 04:04
-
-
Save rayworks/6c37a3f197e8c88a6b4370545955df25 to your computer and use it in GitHub Desktop.
Read lines from file in folder asserts
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
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