WEB开发网
开发学院手机开发Android 开发 Android 实现文件 File 读写操作 阅读

Android 实现文件 File 读写操作

 2010-03-25 17:09:00 来源:WEB开发网   
核心提示:return EncodingUtils.getString(array,TEXT_ENCODING);}5. 文件长度Java代码public int length(){return (int)file.length();}public int length(){return (int)file.length();}

return EncodingUtils.getString(array,TEXT_ENCODING);

}

5. 文件长度

Java代码

public int length(){

return (int)file.length();

}

public int length(){

return (int)file.length();

}

6. 如何使用FileIOHelper

Java代码

public class FileIOUsage extends Activity {

public final static String NAME = "griffinshi.txt";

public final static String PATH = "data/data/com.android.FileIO";

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//setContentView(R.layout.main);

try {

FileIOHelper helper = new FileIOHelper(this,NAME,PATH );

String string = "Hello to Gryphone!";

helper.wrire(string);

byte[] array = helper.read(0, helper.length());

String data = helper.encode(array);

TextView tv = new TextView(this);

tv.setText(data);

setContentView(tv);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

public class FileIOUsage extends Activity {

public final static String NAME = "griffinshi.txt";

public final static String PATH = "data/data/com.android.FileIO";

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//setContentView(R.layout.main);

try {

FileIOHelper helper = new FileIOHelper(this,NAME,PATH );

String string = "Hello to Gryphone!";

helper.wrire(string);

byte[] array = helper.read(0, helper.length());

Tags:Android 实现 文件

编辑录入:coldstar [复制链接] [打 印]
赞助商链接