read text file in raw folder into array list (UTF16 applied)
refer to myHolyBible.app
ArrayList<String> readRawTextFile(Context ctx, int resId)
{
ArrayList<String> lines = new ArrayList<String>();
InputStream inputStream = ctx.getResources().openRawResource(resId);
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(inputStream,"UTF16"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String line = "";
while (line != null) {
try {
line = reader.readLine();
if (line != null)
lines.add(line);
else
break;
} catch (IOException e) {
line = null;
}
}
return lines;
}
'android source ' 카테고리의 다른 글
mp3 media play (0) | 2019.08.17 |
---|---|
To get the Camera full folder name (0) | 2019.08.17 |
get color table int (0) | 2019.07.28 |
hander message pass (0) | 2019.07.28 |
sleep (0) | 2019.07.28 |