1
How do I read as string an Android text file that is inside the Assets folder?
1
How do I read as string an Android text file that is inside the Assets folder?
1
getAssets().open()
will return a InputStream
.
Read it using the standard Java input and output API (I/O). As in the following example:
StringBuilder buf=new StringBuilder();
InputStream json=getAssets().open("book/contents.json");
BufferedReader in=
new BufferedReader(new InputStreamReader(json, "UTF-8"));
String str;
while ((str=in.readLine()) != null) {
buf.append(str);
}
in.close();
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.