This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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.
Joined: Aug 17, 2007
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.