res > raw > kword2 라는 resource를 array file로 읽어들임
textArray = readTextFileFromRawResource(R.raw.kword2);
private ArrayList<String> readTextFileFromRawResource(int resourceId) {
ArrayList<String> lines = new ArrayList<>();
try {
InputStream inputStream = getResources().openRawResource(resourceId);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
reader.close();
} catch (IOException e) {
Log.e("Exception", "Reading "+e);
}
return lines;
}
'android source ' 카테고리의 다른 글
String Utility (0) | 2024.09.16 |
---|---|
Notification 보내기 (0) | 2024.09.16 |
toolbar back button 추가 (0) | 2024.09.16 |
menu 폭 줄이는 법 (0) | 2024.08.17 |
code page 설정하여 파일 읽고 쓰기 (0) | 2024.08.08 |