Provides the state of a file or directory, File attributes at a point in time.
Following is the declaration for org.apache.commons.io.monitor.FileEntry Class −
public class FileEntry extends Object implements Serializable
FileEntry class object provides following file attributes at a point in time.
Here is the input file we need to parse −
Welcome to Howcodex. 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()); } }
It will print the following result.
Monitored File: input.txt File name: input.txt Is Directory: false