2

I'm trying to get the date of a file which is in a Apache vfs.

There is a getAttribute-Method in org.apache.commons.vfs2.FileSystem, but I can't find any examples on how to use it. I'm pretty sure that it is possible by using this method. The parameter is a String and i have no idea, which String represents the Date of a File.

LaaKii
  • 95
  • 11

1 Answers1

1

You may want to have a look at the FileContent class, method getLastModifiedTime().

protected static void printModificationDateOfItemsInFolder(final StandardFileSystemManager fsManager, final URI folderUri) throws FileSystemException {
        try (final FileObject localFileObject = fsManager.resolveFile(folderUri)) {
            final FileObject[] children = localFileObject.getChildren();
            for (int i = 0; i < children.length; i++) {
                try (final FileContent content = children[i].getContent()) {
                    System.out.println("Modification [timestamp=" + content.getLastModifiedTime() + "] [file/dir=" + children[i].getName().getBaseName() + "]");
                }
            }
        }
}