Reputation: 1633
I would like to check the below in my java spring project.
Ftp path:-
ftp://mmepx/gpi/nsdsdfdt/fromDIR
1) I want to check if the above mentioned FTP path is working and accessible for writing in that folder "fromDir
I am using JDK1.6 and spring.
Appreciate any help.
Thanks
Upvotes: 1
Views: 1049
Reputation: 61865
Use an FTP client/library and try the desired operation, such as PUT'ting a file. If it doesn't work, well - the resource (server, path, etc) didn't exist, wasn't writable, or otherwise wasn't accessible.
FTP doesn't allow a way of querying if a directory is writable or if an operation is allowed, other than trying it. And without actually using FTP, there is no way to tell if the URI is even "valid" for such use.
A common library used is Apache Commons Net (which includes FTP support), but it may be possible to use URLConnection for a simple upload as discussed here.
An aside:
If it is at all possible to avoid FTP, do so! A "drop in" replacement is SFTP, which uses the much more secure SSH stack.
Upvotes: 1