文件属性读取 怎么读取一个文件的详细属性,包括创建时间,修改时间,上次访问时间,文件大小。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 File f = new File(filePath);f.lastModified();//上次时间。。 package com.diablo.utils;import java.io.File;import java.io.InputStream;import java.util.Date;import java.util.Properties;import org.apache.log4j.Logger;/** * 读取用户配置信息 * @author * */public class Props { Logger log = Logger.getLogger(this.getClass()); static private Props instance = null; //唯一实例 static private String propfilename = "/yj_file_conf.properties"; //配置文件 private Properties confProps = new Properties(); private long updateTime = 0; private Props() { init(); } synchronized public static Props getInstance() { if (instance == null) { instance = new Props(); } return instance; } private void init() { InputStream is = getClass().getResourceAsStream(propfilename); try { confProps.load(is); } catch (Exception e) { log.error("不能读取配置文件,请确定conf.properties文件存在!", e); return; } updateTime = new Date().getTime(); } public String getProp(String key) { return (String) confProps.get(key); } public void reload() { log.info("To reload porps"); File file = new File(propfilename); long newTime = file.lastModified(); if (newTime != updateTime) { log.info("reload porps start"); InputStream is = getClass().getResourceAsStream(propfilename); try { confProps.load(is); } catch (Exception e) { log.error("不能读取配置文件,请确定conf.properties文件存在!", e); return; } updateTime = newTime; log.info("reload porps end"); } }} 运行之后得到的数跟实际的不一致啊,求问题所在? 求教 ubuntu 下的scim 输入法问题 关于表数据刷新,增加一列之后,jtable java如何实现启动窗口自动最大化? "/u00ff"的问题 关于Java Swing JTable 生成表格形式的问题,望高手告知! 老大们请问,jdk1.5中没有javac这个命邻,哪如何编译呀?用哪个命邻呀?急急急! jdk配置 背景图片尺寸问题 学习<Think in Java>第2章的问题,欢迎大家讨论。 eclipse中通过ant task 去调用java类 java jdbc操作mysql数据库
f.lastModified();//上次时间
。。
import java.io.File;
import java.io.InputStream;
import java.util.Date;
import java.util.Properties;import org.apache.log4j.Logger;/**
* 读取用户配置信息
* @author
*
*/
public class Props { Logger log = Logger.getLogger(this.getClass()); static private Props instance = null; //唯一实例 static private String propfilename = "/yj_file_conf.properties"; //配置文件 private Properties confProps = new Properties(); private long updateTime = 0; private Props() {
init();
} synchronized public static Props getInstance() {
if (instance == null) {
instance = new Props();
}
return instance;
} private void init() {
InputStream is = getClass().getResourceAsStream(propfilename);
try {
confProps.load(is);
} catch (Exception e) {
log.error("不能读取配置文件,请确定conf.properties文件存在!", e);
return;
}
updateTime = new Date().getTime();
} public String getProp(String key) {
return (String) confProps.get(key);
} public void reload() {
log.info("To reload porps");
File file = new File(propfilename);
long newTime = file.lastModified();
if (newTime != updateTime) {
log.info("reload porps start");
InputStream is = getClass().getResourceAsStream(propfilename);
try {
confProps.load(is);
} catch (Exception e) {
log.error("不能读取配置文件,请确定conf.properties文件存在!", e);
return;
}
updateTime = newTime;
log.info("reload porps end");
}
}}