1.继承结构:
java.lang.Object | ||
? | java.io.OutputStream | |
? |
java.io.FileOutputStream |
package org.lxh.demo; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Hello extends Activity { private static final String FILENAME = "test.txt"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 生命周期方法 super.setContentView(R.layout.main); // 设置要使用的布局管理器 FileOutputStream output = null; try { output = super.openFileOutput(FILENAME, Activity.MODE_PRIVATE); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } PrintStream out = new PrintStream(output);//打印流包装 out.println("姓名:张亚运;"); out.println("年龄:25;"); out.println("地址:江苏省南京市"); out.close(); } }
导出文件打开如下:
原文地址:http://blog.csdn.net/yayun0516/article/details/43763387