1

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

mahesh
  • 1,523
  • 4
  • 23
  • 39
  • Ok thanks, but FTP Client means, any example ,you mean write the java code to connect to the ftp site? – mahesh Feb 05 '14 at 00:00

1 Answers1

1

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.

Community
  • 1
  • 1
user2864740
  • 60,010
  • 15
  • 145
  • 220
  • thanks for the info, as per my requirment, i will be only given the FTP url as mentioned in my post. Do i need to modify that URL or can I pass the same as FTP server using FTPClient – mahesh Feb 05 '14 at 00:06
  • @mahesh It will depend on the FTP client/library (I've never used the one from Apache Commons), but generally one would connect to the server (`mmepx` via the `ftp` protocol) and then issue FTP commands - such as GET and PUT - against the path (`/gpi/nsdsdfdt/fromDIR`) once connected. However, the library/client used may provide smarter URI handling or appropriate wrapper methods. YMMV. – user2864740 Feb 05 '14 at 00:08
  • 1
    @mahesh I've added a link to http://stackoverflow.com/a/17454840/2864740 which proposes using URLConnection (which *is* standard). I've never tried it. YMMV. – user2864740 Feb 05 '14 at 00:18
  • excellent, thank you so much. I think that will help me complete my requirement – mahesh Feb 05 '14 at 00:43