社区
Java SE
帖子详情
文件属性读取
mzhjlong
2009-03-31 04:59:08
怎么读取一个文件的详细属性,包括创建时间,修改时间,上次访问时间,文件大小。。。。
...全文
56
2
打赏
收藏
文件属性读取
怎么读取一个文件的详细属性,包括创建时间,修改时间,上次访问时间,文件大小。。。。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wdj926
2009-04-01
打赏
举报
回复
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");
}
}
}
漫无目的行走的月亮
2009-03-31
打赏
举报
回复
File f = new File(filePath);
f.lastModified();//上次时间
。。。。。
java
读取
属性文件
java
读取
属性文件通用方法,以及日志记录
shp线文件
读取
的C++代码
基于C++的代码,能够读写shp线文件,也可简单修改读写点面文件
C语言对HDF文件数据集和属性的读写[文].pdf
C语言对HDF文件数据集和属性的读写[文].pdf
Spring Boot 自定义配置文件及配置
文件属性
读取
Spring Boot 自定义配置文件及配置
文件属性
读取
一.
读取
核心配置文件 核心配置文件是指在resources根目录下的application.properties或application.yml配置文件,
读取
这两个配置文件的方法比较简单 application...
java
读取
文件属性
_java
读取
属性文件
不过这些信息一般都是比较少的数据,没有必要使用数据库文件来保存,而使用一般的文本文件来保存,如果是通过File直接保存的话,可能在存储和
读取
上都 不是很方便,但如果保存为Properties文件就不一样了,...
Java SE
62,614
社区成员
307,327
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章