Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FTP

 
sankar singh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a small file transfer program in JAVA. how to define sepefic file meaing i want to define spefic directory and then file. Can anyone provide a sample code its urgent. And i want to send all the files from specific folder when new file arrives into that folder.
regards,
sankar.s
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to implement FTP as defined by the RFC's? or just a file transfer protocol that you have to design?

if you mean your own hand invented protocol, just send a 'command' message the declares the directory and file name, preferably with relative addressing.
Use the standard Java API to set the working directory, and check to see if the file exists. (you could just clobber it, but that is bad form.)

If it doesn't exist, create it.

Then transfer the data bytes over the socket and close the file when the socket is closed.
 
sankar singh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am not defining own protocol, just i want to transfer a file from one machine to another machine using FTP. If you send me the code that would be great.

Thats it.

Regards,

Sankar.S
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jakarta Commons Net library implements an easy-to-use FTP client. Study the javadocs of the FTPClient class for an example of its use.
 
Van Glass
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you might also look at this library

http://www.jscape.com/sftp/

supports FTP, FTPS and SFTP protocols.
 
Prafulla N. Patil
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer : Can we do Secured FTP with The Jakarta Commons Net library?

if yes how to do that

i have gone through the javadoc but i am not getting how to do that or it is possible or not ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Commons Net does not support any of the secure FTP variants, but apparently the jscape.com product mentioned above does.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic