Contact at or 8097636691
Responsive Ads Here

Saturday, 30 June 2018

Apache Commons IO - FileEntry

Apache Commons IO - FileEntry

Provides the state of a file or directory, File attributes at a point in time.

Class Declaration

Following is the declaration for −
public class FileEntry
   extends Object implements Serializable


FileEntry class object provides following file attributes at a point in time.
  • getName() − file name.
  • exists() − checks if file exists or not.
  • isDirectory() − checks if file is a directory.
  • lastModified() − gives last modified date time.
  • listFiles() − gives content of directory.

Example of FileEntry Class

Here is the input file we need to parse −
Welcome to TutorialsPoint. Simply Easy Learning.


public class IOTester {
   public static void main(String[] args) {
      try {
      } catch(IOException e) {

   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

No comments:

Post a Comment