ReadAsset.java
package com.example.androidapi.content;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import com.example.androidapi.R;
public class ReadAsset extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.read_asset);
try {
InputStream is = getAssets().open("read_asset.txt");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String text = new String(buffer);
TextView tv = (TextView)findViewById(R.id.text);
tv.setText(text);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
最后
以上就是寂寞小鸭子最近收集整理的关于android中读取asset文件夹下的文件的全部内容,更多相关android中读取asset文件夹下内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复