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

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://bzwzjz.com/article/dojghj.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站设计公司 成都网站制作 手机网站制作设计 网站建设开发 上市集团网站建设 企业网站设计 网站制作公司 营销型网站建设 成都网站建设公司 盐亭网站设计 响应式网站设计 成都网站制作 成都企业网站制作 成都网站建设 高端网站设计 网站建设改版 手机网站制作 成都网站设计 成都网站建设公司 成都网站制作 专业网站设计 攀枝花网站设计