Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.8k views
in Java FTP by
FTPClient locks file after "put" throws exception. The lock is still there even after "quit" method is called.

FTPClient ftp_client = null;
try{
ftp_client = getFTPClient();
ftp_client.chdir(workingRemoteFilePath);
ftp_client.put( workingLocalFile.getPath(), workingRemoteFileName );
ftpUploadSuccessful = true;
processSession.addAudit(this, "File " + workingLocalFile + " uploaded to " +
workingRemoteFilePath + "\\" + workingRemoteFileName );
}catch(Exception e){
processSession.addErrorAudit(this, "Exception uploading file " + workingLocalFile + " to " +
workingRemoteFilePath + "\\" + workingRemoteFileName, e );
throw e;
}finally{
/* quite to release local file */

if (ftp_client != null){
if ( LOG.isDebugEnabled() ) LOG.debug("Quitting FTP Client");
try{ftp_client.quit();}
catch(Exception e){LOG.error("Exception quitting FTPClient", e);}
}
System.out.println("LLLLLLLLLLLLLLLLLLLLLLLLLLL " +
workingLocalFile.delete() );
}

output:

[java] DEBUG [main] process.FTPProcessComponent (?:?) - Quitting FTP Client
[java] LLLLLLLLLLLLLLLLLLLLLLLLLLL false

6 Answers

0 votes
by
I have a similar problem even the put opertation is successful I cant delete the local file. Why FTPClient still holds the file's lock?[/quote]
0 votes
by (162k points)
What version are you using?

I have a similar problem even the put opertation is successful I cant delete the local file. Why FTPClient still holds the file's lock?
[/quote]
0 votes
by
[quote="support2"]What version are you using?
1.5.0
same with 1.4.9 and 1.4.8
0 votes
by
Sorry I have seen that in the code I forget to close the BufferedInputStream of the local file. Thats why it couldnt delete the local file.
0 votes
by
Sorry I have seen that in the code I forget to close the BufferedInputStream of the local file. Thats why it couldnt delete the local file.
0 votes
by (162k points)
We didn't or you didn't? I think we do ...

Sorry I have seen that in the code I forget to close the BufferedInputStream of the local file. Thats why it couldnt delete the local file.

Categories

...