转载:一种不通过程序来实现写作和阅读文件的方法
2010-01-19 16:04
615 查看
转载自:www.madhome.org
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);
}
}
}
一种不通过程序来实现写作和阅读文件的方法
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);
}
}
}
相关文章推荐
- 通过CMWAP下载大文件一种实现方法
- 本文给出了一种方便实用的解决大文件的读取、存储等处理的方法,并结合相关程序代码对具体的实现过程进行了介绍
- [转]VC: 非MFC程序TRACE和ASSERT宏的一种实现方法
- Go -- 通过GOTRACEBACK生成程序崩溃后core文件的方法(gcore gdb)
- 通过文件锁实现,程序开始运行时,先判断文件是否存在,若存在则表明该程序已经在运行了,如果不存在就用open函数创建该文件,程序退出时关闭文件并删除文件
- C#实现程序启动唯一实例的一种方法
- 通过程序实现文件下载更名,动态文件下载
- PHP 实现一种多文件上传的方法
- [导入]在C#中启动另一个程序的实现方法[转载]
- 一种简单的方法在程序中实现透明效果(JAVA)
- VC++实现程序重启的方法(转载)
- VC++ 6.0中建立和运行包含多个文件的程序的方法(转载)
- init.rc文件里面启动c++程序,通过jni调用java实现
- 位图文件(BMP)格式分析以及程序实现[转载]
- WinCE C#程序,控制启动时仅仅能启动一个程序,使用相互排斥量来实现,该实现方法測试通过
- 通过隐藏iframe实现文件下载的js方法
- linux 通过脚本实现自动重启程序的方法
- Python通过解析网页实现看报程序的方法
- iphone程序中实现截屏的一种方法
- 通过AutoConfig实现Form Server配置文件的修改 【转载】