比较hadoop hdfs中的时间戳

svdrlsy4  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(198)

我是新来的 hadoop 我和大家都有个问题要问。有没有办法比较hdfs中两个文件之间的时间戳?
非常感谢您的帮助。

eagi6jfj

eagi6jfj1#

使用filesystem.getfilestatus(path)方法获取一个filestatus对象,从中可以通过filestaus.getmodifiedtime()方法获取文件的修改时间

FileSystem fs = FileSystem.get(conf);
long ts1 = fs.getFileStatus(new Path("/path/to/file1")).getModifiedTime();
long ts2 = fs.getFileStatus(new Path("/path/to/file2")).getModifiedTime();

相关问题