Properties settings = new Properties();
try{
settings.load(new FileInputStream("count.txt")); //加载文件.
}catch(IOException e){
settings.setProperty("count", String.valueOf(0));
}
int c = Integer.parseInt(settings.getProperty("count"))+1;
System.out.println("运行了第"+c+"次!"); //打印
settings.setProperty("count", new Integer(c).toString()); //保存count属性
try{
settings.store(new FileOutputStream("count"), "used for count"); //保存到文件
}catch(IOException e){
e.printStackTrace();
}
问:帮我看看哪里有错,我找不到,谢谢咯。
解决方案 »
- 如何把目录下文件名写到一个list中去?
- 为什么可以通过编译却不能运行?
- 郁闷,面板上有个JLabel,我把它的Text值删除掉后,如何选择这个JLabel
- 走过路过还要错过呀~~~
- 北京叁壹伍捌国际信息技术有限公司笔试题
- jsp页级变量
- 急,高分求教!!!
- java尤其j2ee的技术那么多,开源又那么丰富,你们公司在实际项目中用到了哪些呢?参与者都有分!
- java面向对象编程—————————编译包,执行时出现异常
- 用Socket连接后能不能直接发送一个数组?
- 一个循环的问题!求围观啊
- Can you tell the differences between the two sentences?
settings.load(new FileInputStream("count.txt")); //加载文件.
修改如下:
settings.load(new FileInputStream(new File("d:"+File.separator+"count.txt")));
The method getProperty(String) is undefined for the type Properties
The method setProperty(String, String) is undefined for the type Properties
The method store(FileOutputStream, String) is undefined for the type Properties at com.propertiesfile.Properties.main(Properties.java:13)(也就是大哥你说的这行)
我已经引入util包和io包了,好像没有找到count.txt,真找不到是什么问题,按 你这样子改也不行。