This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes FTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "FTP " Watch "FTP " New topic
Author

FTP

sankar singh
Ranch Hand

Joined: Aug 17, 2007
Posts: 40
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

Joined: Aug 11, 2007
Posts: 4646
    
    5

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

Joined: Aug 17, 2007
Posts: 40
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
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
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.


Ping & DNS - my free Android networking tools app
Van Glass
Ranch Hand

Joined: Nov 18, 2000
Posts: 110
you might also look at this library

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

supports FTP, FTPS and SFTP protocols.
Prafulla N. Patil
Ranch Hand

Joined: Mar 20, 2006
Posts: 106
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 ?


Thanks, Prafulla Patil
SCJP, SCWCD
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
Commons Net does not support any of the secure FTP variants, but apparently the jscape.com product mentioned above does.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FTP
 
Similar Threads
Move file from Windows to FtpServer(Unix)
"Java Source" in CVS and WSAD
FTP
how to use MSSQL for JMS
Path to store Embedded Database files