读书人

资料存储

发布时间: 2013-04-02 12:35:26 作者: rapoo

文件存储
public class FileOutput extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.activity_main);try{OutputStream os = openFileOutput("file.txt", Activity.MODE_PRIVATE);String str1 = "《Android/OPhone开发完全讲义》";os.write(str1.getBytes("utf-8"));os.close();InputStream is = openFileInput("file.txt");byte[] buffer = new byte[100];int byteCount = is.read(buffer);String str2 = new String(buffer, 0, byteCount, "utf-8");TextView textView = (TextView)findViewById(R.id.tv01);textView.setText(str2);is.close();}catch (Exception e) {}} }

?

读书人网 >移动开发

热点推荐