程序不报错,为什么不生成count.txt文件呢,次数c也不递增,求教?
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class Propertie {
public static void main(String[] args) {
// TODO Auto-generated method stub
Properties setting = new Properties();
try {
setting.load(new FileInputStream("D:\\count.txt"));
} catch (FileNotFoundException e) {
setting.setProperty("count", String.valueOf(0));
} catch (IOException e) {
e.printStackTrace();
}
int c = Integer.parseInt(setting.getProperty("count")) + 1;
System.out.println("这是第:" + c + "次运行");
setting.setProperty("count", new Integer(c).toString());
try {
setting.store(new FileOutputStream("count.txt"),"Progrom is used:");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} |
|