当前位置: 首页 > news >正文

动易网站首页制作/最全的搜索引擎

动易网站首页制作,最全的搜索引擎,做爰全过程的视频网站,男女直接做那个的视频网站内容:Properties基本存取、存储到持久化设备、从持久化设备读取、简单模拟收费软件试用结束##Properties——有配置文件的功能。 特点: 1、Hash table的子类,map集合中的方法都可以用 2、该集合没有泛型。键值都是字符串 3、是一…

内容:Properties基本存取、存储到持久化设备、从持久化设备读取、简单模拟收费软件试用结束
##
Properties——有配置文件的功能。
    特点:
    1、Hash table的子类,map集合中的方法都可以用
    2、该集合没有泛型。键值都是字符串
    3、是一个持久化的属性集,键值可以保存到集合和持久化设备上,键值的来源也可以是持久化设备。

##########################################################
基本存取

public class PropertiesDemo
{public static void main(String[] args){methodDemo();} public static void methodDemo(){//Properties基本存取Properties prop = new Properties();prop.setProperty("xlsg", "21");prop.setProperty("qldk", "20");
//        prop.list(System.out);   //这个方法调试使用Set<String> set = prop.stringPropertyNames();for(String name:set){String value = prop.getProperty(name);System.out.println(name+"__"+value);}}
}

 

#######################################################################
存储到持久化设备

通过Properties的store方法指定保存到什么文件里面

public class PropertiesDemo
{public static void main(String[] args) throws IOException{methodDemo();}public static void methodDemo() throws IOException{//Properties基本存取Properties prop = new Properties();prop.setProperty("xlsg", "21");prop.setProperty("qldk", "20");//        prop.list(System.out);   //这个方法调试使用
        Set<String> set = prop.stringPropertyNames();for(String name:set){String value = prop.getProperty(name);System.out.println(name+"__"+value);}//永久化存储到设备上FileOutputStream fos = new FileOutputStream("myfile\\we.properties");//使用properties的store方法。prop.store(fos, "my demo , person info");}}

 

#########################################################################################
从持久化设备读取

 

public static void main(String[] args) throws IOException
{
//        methodDemo();
    methodDemo_read();
}private static void methodDemo_read() throws IOException
{File configure_file = new File("myfile\\we.properties");//读取流中的数据Properties prop = new Properties();//定义读取流和数据文件关联FileInputStream fis = new FileInputStream(configure_file.toString());prop.load(fis);prop.list(System.out); //测试使用
    prop.setProperty("xlsg", "22");prop.list(System.out);FileOutputStream fos = new FileOutputStream(configure_file);prop.store(fos, "my demo,person info");fis.close();fos.close();
}

步骤:1)创建properties对象
    2)创建输入流对象
    3)properties对象和输入流对象相关联
    4)通过prop.setProperty("xlsg", "22");进行操作
    5)保存prop.store(fos, "my demo , person info");

 #########################################################################################
简单模拟收费软件试用结束

public static void main(String[] args) throws IOException
{String value = read_count();if(count(Integer.parseInt(value))){//操作value = Integer.toString(Integer.parseInt(value)+1);System.out.println(value);}else{System.out.println("试用结束,请充值!");}write_count(value);
}private static boolean count(int num)
{if(num<5){return true;}return false;
}private static void write_count(String value) throws IOException
{File configure_file = new File("myfile\\count.properties");FileOutputStream fos = new FileOutputStream(configure_file);Properties prop = new Properties();prop.setProperty("count", value);prop.store(fos, "tryout count");fos.close();
}private static String read_count() throws IOException
{File configure_file = new File("myfile\\count.properties");if(!configure_file.exists()){configure_file.createNewFile();}FileInputStream fis = new FileInputStream(configure_file);Properties prop = new Properties();prop.load(fis);String value;String key = "count";if(prop.containsKey(key)){}else{prop.setProperty(key, "0");}value = prop.getProperty(key);return value;}
my code
public static void main(String[] args) throws IOException {/** 练习:定义功能记录程序运行次数,满足试用次数后,给出提示:试用次数已到,请注册。* * 思路:* 1,需要计数器。这个软件使用一次计数一次。每使用一次,就进行计数累计。* 2,计数器是程序中的一个变量,程序启动计数器计数,可是程序结束这个计数器就消失了。* 下次启动会重新进行计数,原来计数的值没有保留下来。咋办?* 3,让这个计数器持久化。存储到文件中,为了标识数据可读性,数据起个名字。出现键值对。* 而且还是一个持久化的键值对,Properties集合正好符合这个要求。* */if(isStop()){System.out.println("试用次数已到,请注册");return;}runcode();
}private static boolean isStop() throws IOException {//1,配置文件。File configFile = new File("tempfile\\app.properties");if(!configFile.exists()){//如果配置文件不存在,就创建。
        configFile.createNewFile();}//2,创建属性集。Properties prop = new Properties();//3,定义读取流和配置文件关联。FileInputStream fis = new FileInputStream(configFile);//4,将流关联的数据读取到属性集中。
    prop.load(fis);//5,通过属性集的指定键count,获取具体的次数。String value = prop.getProperty("count");int count = 0;//6, 对value进行判断,如果存在就对其自增。if(value!=null){count = Integer.parseInt(value);if(count>=5){return true;}}count++;//对其值进行自增。//7,将自增后的值和指定的键重新存储到属性集中,键相同,值覆盖。prop.setProperty("count", Integer.toString(count));//8,将属性集存储到配置文件中。对配置文件中的信息进行更新。FileOutputStream fos = new FileOutputStream(configFile);prop.store(fos, "app run count");//9,关闭资源。
    fos.close();fis.close();return false;
}
//程序主体。
public static void runcode(){System.out.println("程序运行....play");
}
the answer

 

转载于:https://www.cnblogs.com/-nbloser/p/9009599.html

http://www.lbrq.cn/news/1442881.html

相关文章:

  • 建电影网站教程/百度统计登录
  • 企业网站建设遵循的原则/网店运营流程步骤
  • 廊坊建站模板系统/广告推广方案
  • 在线考试类网站怎么做/百度网盘官网下载
  • 海淀网站建设联系方式/关键词排名优化流程
  • 做网站办公照片/百度视频推广怎么收费
  • 网站建设关键字/网站seo课程
  • 网站首页滚动图片用dw怎么做/国外独立网站如何建站
  • 服务型网站有哪些/友情链接网自动收录
  • 西安做网站的/百度官方网页
  • 网站宣传页/上海百度关键词优化公司
  • 河北斯皮尔网站建设/舆情网站直接打开
  • 镇江有哪些网站/个人接app推广单去哪里接
  • 建设银行宁德分行网站/seo网站内部优化
  • 建立独立网站/泰安网站seo
  • 海报设计 网站/百度人工客服24小时电话
  • 网站开发环境与工具/百度百家号登录入口
  • html5动态网站模板/seo关键字优化
  • 电力建设工程质监总站网站/江苏免费关键词排名外包
  • 做网站的好处和坏处/餐饮营销策划与运营
  • 装修设计费/安卓优化大师2023
  • 免费咨询服务合同模板/西安seo网站优化
  • 云建站不能用了吗/军事新闻
  • 郑州专业做网站多少钱/互联网培训
  • 政务公开既网站信息化建设会议/提升关键词排名seo软件
  • 农行网站不出动画怎么做/日照网络推广
  • 抖音同步wordpress/新乡网站优化公司价格
  • 阿里云做网站需要环境/网店推广营销方案
  • b2c模式的电商网站发展趋势/推广方案策划
  • 门户网站模板之家/软件拉新推广平台
  • 基于Python的《红楼梦》文本分析与机器学习应用
  • Redis RDB和AOF 流程、优缺点详细介绍
  • [Element-plus]动态设置组件的语言
  • Kubernetes生产环境健康检查自动化指南
  • 教程 | Win11彻底关闭“推荐的项目“,解放开始菜单! (Windows11推荐项目设置器)
  • 《设计模式》策略模式