当前位置:编程学习 > JAVA >>

菜鸟求问

import java.util.Properties;

import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

public class PropertiesFile {

/**
 * @throws IOException
 * @
 */
public static void main(String[] args) throws IOException {
Properties settings = new Properties();

FileInputStream count = null;
try {
count = new FileInputStream(new File(new URI("file:///d:/count.txt")));
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
settings.setProperty("count",String.valueOf(0));
}
settings.load(count);
int c = Integer.parseInt(settings.getProperty("count"))+1;
System.out.println("这是第" + c + "次运行!!!!!");
        settings.setProperty("count",new Integer(c).toString());
        settings.store(new FileOutputStream("file:///d:/count.txt"), "程序被应用!!!!!");
}

}
怎么作?实现显示第几次运行 java 类 应用 --------------------编程问答-------------------- --------------------编程问答-------------------- 运行一次,修改文件的值,再读出来,貌似是这么做 --------------------编程问答-------------------- 你这想法不是挺好的么。。。
试试
settings.store(new FileOutputStream("d:/count.txt"), "程序被应用!!!!!");
补充:Java ,  Eclipse
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,