91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

數據的保存和讀取

發布時間:2020-07-14 13:58:41 來源:網絡 閱讀:566 作者:lang螞蟻 欄目:軟件技術

1數據的保存

btn_ok.setOnClickListener(new OnClickListener() {

                              @Override

                              public void onClick(View v) {

                                        String user = et_user.getText().toString().trim();

                                        String pwd = et_pwd.getText().toString().trim();

                                        if(user.isEmpty()||pwd.isEmpty()){

                                                  Toast.makeText(getApplicationContext(), "不能為空", 200).show();

                                        }else{

                                                   

                                                  String name="data.txt";

                                                  String content=user+"="+pwd;

                                                  try {

                                                   FileOutputStream fos=openFileOutput(name, MODE_PRIVATE);

                                                  

                                                   fos.write(content.getBytes());

                                                  

                                                   fos.close();

                                                             

                                                   Toast.makeText(getApplicationContext(), "保存成功", 200).show();

                                                   

                                                  } catch (Exception e) {

                                                            // TODO Auto-generated catch block

                                                            e.printStackTrace();

                                                  }

                                        }

                               

                              }

                    });

 

 

 

 

2,數據的讀取

 

 

btn_show.setOnClickListener(new OnClickListener() {

                               

                              @Override

                              public void onClick(View v) {

                                        String name="data.txt";

                                        try {

                                                  FileInputStream fis=openFileInput(name);

                                                  BufferedReader br=new BufferedReader(new InputStreamReader(fis));

                                                  //讀取文檔的數據

                                                  String content = br.readLine();

                                                  //拆分字符串

                                                  String[] strs = content.split("=");

                                                  //顯示的數據

                                                  if(!content.isEmpty()){

                                                            et_user.setText(strs[0]);

                                                            et_pwd.setText(strs[1]);

                                                  }

                                        } catch (Exception e) {

                                                  // TODO Auto-generated catch block

                                                  e.printStackTrace();

                                        }          

                              }

                    });

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

长武县| 平原县| 郸城县| 清原| 勐海县| 大悟县| 桑植县| 铁力市| 锡林郭勒盟| 南汇区| 西城区| 利川市| 泸西县| 柳河县| 嘉鱼县| 丹江口市| 凤山市| 鄂托克旗| 江油市| 区。| 耿马| 康平县| 梨树县| 西华县| 开化县| 宁波市| 徐州市| 无锡市| 大名县| 红桥区| 岑巩县| 沐川县| 桐庐县| 伊宁县| 博白县| 临颍县| 大石桥市| 梓潼县| 大田县| 贡嘎县| 汝南县|