189 8069 5689

数据的保存和读取-创新互联

1数据的保存

红古ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

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();

                                        }

                              }

                    });

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站题目:数据的保存和读取-创新互联
浏览路径:http://cdxtjz.com/article/dojghj.html

其他资讯