📅  最后修改于: 2020-11-18 08:18:12             🧑  作者: Mango
提供某个时间点文件或目录的状态,文件属性。
以下是org.apache.commons.io.monitor.FileEntry类的声明-
public class FileEntry
extends Object implements Serializable
FileEntry类对象在某个时间点提供以下文件属性。
这是我们需要解析的输入文件-
Welcome to TutorialsPoint. Simply Easy Learning.
IOTester.java
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.monitor.FileEntry;
public class IOTester {
public static void main(String[] args) {
try {
usingFileEntry();
} catch(IOException e) {
System.out.println(e.getMessage());
}
}
public static void usingFileEntry() throws IOException {
//get the file object
File file = FileUtils.getFile("input.txt");
FileEntry fileEntry = new FileEntry(file);
System.out.println("Monitored File: " + fileEntry.getFile());
System.out.println("File name: " + fileEntry.getName());
System.out.println("Is Directory: " + fileEntry.isDirectory());
}
}
它将打印以下结果。
Monitored File: input.txt
File name: input.txt
Is Directory: false