반응형
This file contains hidden or 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
private Spanned readTxt(int textFileResId) { | |
if (textFileResId <= 0) { | |
return new SpannedString(""); | |
} | |
String data = null; | |
InputStream inputStream = getContext().getResources().openRawResource(textFileResId); | |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | |
int i; | |
try { | |
i = inputStream.read(); | |
while (i != -1) { | |
byteArrayOutputStream.write(i); | |
i = inputStream.read(); | |
} | |
data = new String(byteArrayOutputStream.toByteArray(), "UTF-8"); | |
inputStream.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return Html.fromHtml(data); | |
} |
반응형
'Tech develop > Android' 카테고리의 다른 글
[Android/안드로이드]Activity Shared Elements Transitions(액티비티 이동 애니메이션) (0) | 2016.04.25 |
---|---|
[android]device model info. 기기 모델 정보 가져오기 (0) | 2016.04.14 |
[android]6.0이상의 폰에서 runtime permission 처리 (0) | 2016.03.10 |
[Android]File Upload 시 Progress 보여주기 (0) | 2016.03.10 |
[Android]realm 적용하기 (0) | 2015.12.10 |