您的位置:首页 > 其它

转载:一种不通过程序来实现写作和阅读文件的方法

2010-01-19 16:04 615 查看
转载自:www.madhome.org

一种不通过程序来实现写作和阅读文件的方法

package com.saamy.net;
import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AndroidUI extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
InputStream is = getAssets().open("lan.txt");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String text = new String(buffer);
long x = 1000;

TextView tv = (TextView)findViewById(R.id.tv);
tv.setText(text);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: