- public class RunCount {
- public static void main(String[] args) throws Exception
- {
- Properties prop=new Properties();
- File file=new File("d:\\work\\count.ini");
- if(!file.exists())
- file.createNewFile();
- FileInputStream fis=new FileInputStream("file");
-
- prop.load(fis);
-
- int count=0;
- String value=prop.getProperty("time");
- if(value!=null)
- {
- count=Integer.parseInt(value);
- if(count>=5)
- {
- System.out.println("次数已到,请投币= =!");
- }
- }
- count++;
- prop.setProperty("time", count+"");
- FileOutputStream fos=new FileOutputStream(file);
- prop.store(fos,"");
- fos.close();
- fis.close();
- }
- }
复制代码
为啥我的就弹错呢。。。不管文件在不在,都提示
Exception in thread "main" java.io.FileNotFoundException: file (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at io.RunCount.main(RunCount.java:44) |
|