- import java.io.*;
- import java.util.*;
- class PropertiesDemo
- {
- public static void main(String[] args) throws IOException
- {
- Properties prop = new Properties();
- File file = new File("F:\\count.ini");
- if(!file.exists())
- file.createNewFile();
- FileInputStream fis = new FileInputStream(file);
- prop.load(fis);
- String value =prop.getProperty("time");
- int count = 0;
- if(value!=null)
- {
- count=Integer.parseInt(value);
- if(count>=5)
- {System.out.println("给钱");
- return ;}
-
- }
- count++;
- prop.setProperty("time",count+"");//为什么这句话可以打印键值对,不懂 求解析
- FileOutputStream fos = new FileOutputStream(file);
- prop.store(fos," ");
- fis.close();
- fos.close();
- }
- }
复制代码
帮忙 |
|