DEV Community

loading...
Cover image for How to scan the file system in Java

How to scan the file system in Java

bw_software profile image Burningwave Updated on ・1 min read

Through FileSystemItem of Burningwave Core library you can reach a resource of the file system even if it is contained in a nested supported (zip, jar, war, ear and jmod) compressed archive and obtain the content of it or other informations such as if it is a folder or a file or a compressed archive or if it is a compressed entry or obtain, if it is a folder or a compressed archive, the direct children or all nested children or a filtered collection of them. You can retrieve a FileSystemItem through an absolute path or through a relative path referred to your classpath by using the PathHelper. FileSystemItems are cached and there will only be one instance of them for an absolute path and you can also clear the cache e reload all informations of a FileSystemItem.

To use FileSystemItem you should simply add the following to your projects dependencies:

In this example we show how to retrieve and use a FileSystemItem:

In this article we learned how to scan the file system and the complete source of this example is available here.

Discussion (0)

pic
Editor guide