一、解析文本文件
// 解析Asset 数据
AssetManager assetManager = getAssets();
try
{
String str = readStream(assetManager.open("data.txt"));
((TextView) findViewById(R.id.txAssets)).setText(str);
}
catch (IOException e)
{
e.printStackTrace();
}
private String readStream(InputStream is)
{
try
{
ByteArrayOutputStream bo = new ByteArrayOutputStream();
int i = is.read();
while (i != -1)
{
bo.write(i);
i = is.read();
}
return bo.toString();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
return "";
}
}
<