Reputation: 1179
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.
Upvotes: 7
Views: 7266
Reputation: 1264
You can also have a glance at the new package nio.2 in Java 7, with tutorial here.
Many new and powerful things.
Upvotes: 2
Reputation: 15844
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
}
Upvotes: 7
Reputation: 37566
Try to implement a client server application where the server part is installed on your client PC and privides the clietn part (which will run on the Server PC) with the needed information. Alternativly you can use FTP Server on the client machine and access it from the server when needed.
Upvotes: 0
Reputation: 35011
If you can connect via SSH, FTP, or FTPS this can be done fairly easily. If you are talking about HTTP, the server must be set to show directories = true, and you will have to parse the http response for the directory to get the files names.
Upvotes: 0