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

转载自: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);
}
}
}

posted @ 2010-01-19 16:04  jonecard  阅读(154)  评论(0)    收藏  举报