获取文本文件
InputStream is = getAssets().open(fileName);
int lenght = is.available();
byte[] buffer = new byte[lenght];
is.read(buffer);
String result = = new String(buffer, "utf8");
本文介绍了一种使用Android资产文件的方法来读取文本文件,并将其转换为字符串。通过获取输入流,确定文件长度,读取字节,最后用UTF-8编码解析为字符串。
获取文本文件
InputStream is = getAssets().open(fileName);
int lenght = is.available();
byte[] buffer = new byte[lenght];
is.read(buffer);
String result = = new String(buffer, "utf8");
12万+
2800
1万+

被折叠的 条评论
为什么被折叠?
