FTP file copy problem?



Share on Google+Share on Google+

FTP file copy problem?
1 Answer(s)      7 years ago
Posted in : Java Beginners

Can any one tell me how to set file lastModifiedTime after copying files through FTP. I am using commons-net-1.4.1.jar to copy files from local system to server.
Eg: local file name ?test.doc? (Today, December 29, 2009, 5:09:33 PM) when I moving this file to server, the files are moved successfully but the time is updated as server current time. But I need local file time like (Today, December 29, 2009, 5:09:33 PM). Below code I am using for uploading files to server.
File f = new File(localfilePath);
System.out.println("Storing file as remote filename: " + f.getName());
boolean retValue = ftp.storeFile(f.getName(), new FileInputStream(f));
if (!retValue) {
throw new Exception ("Storing of remote file failed. ftp.storeFile()" +
" returned false.");
And also I tried with the below code itself
FTPFile ftp1 = new FTPFile();
String path = ftpRemoteDirectoryPath+localFileName;
System.out.println("The Current File Path is ------->"+path);
The above code is not working. Can anyone please suggest me how solve the problem.
View Answers

January 15, 2010 at 3:27 PM

any one please give the reply.


Related Tutorials/Questions & Answers: