I need to iterate a folder on local machine from the server to parse some files. Is it real? If it's true, please, advise me how to do it.
I prefer Commons VFS. It can handle local filesystems, SFTP and many others. All with the same code - you just change paths to files.
FileSystemManager fsManager = VFS.getManager();
FileObject directory = fsManager.resolveFile("path/to/dir");
FileObject[] files = directory.findFiles(fileSelector);
for (FileObject file : files) {
// do something
}
You can also have a glance at the new package nio.2 in Java 7, with tutorial here.
Many new and powerful things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With