转载:一种不通过程序来实现写作和阅读文件的方法
转载自: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);
}
}
}
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);
}
}
}
浙公网安备 33010602011771号