Note that there are some explanatory texts on larger screens.

plurals
  1. POJava 6 File Deletion with RandomAccessFile
    primarykey
    data
    text
    <p>I am really disappointed to discuss a similar java 6 file deletion issue and not being able to find a solution on these similar posts on flie deletion <a href="https://stackoverflow.com/questions/991489/i-cant-delete-a-file-in-java">Post1</a> and <a href="https://stackoverflow.com/questions/8097067/java-6-file-deletion">Post2</a>.</p> <p>I am working on an application which downloads a file from the FTP Server.This downloading is achieved by obtaining the stream , reading from this stream and writing it to a file <code>RandomAccessFile</code>. In case of corrupt downloads,I wish to delete the file on the disk.</p> <p>I am unable to delete the file manually or via the application.It is very obvious that some file handler still has the lock for the file due to which file deletion is a failure. However,I cant understand which file handlers possesses the file lock as I have made sure that I close all the file and the stream objects. </p> <p>Finally,the code snippet</p> <pre><code>public class OprDownload extends Observable implements Runnable { public void run() { //Code to connect to ftp,obtain the stream and write to a file if (download complete) { if(mwwObjFile!=null) { mwwObjFile.close(); } if(stream!=null) { stream.close(); } if(compareChecksum())//If checksum match success { updateDownloadDetails(); cwwIntStatus = COMPLETE; } else { cwwIntStatus = CHECKSUM_FAIL; deleteCorruptUpdateFromDownloadsFolder(); } } } public void deleteCorruptUpdateFromDownloadsFolder() { String fileOndisk = "FileName"; File mwwFileToBeDeleted = new File(fileOndisk ); if(mwwFileToBeDeleted .exists()) { System.out.println("File Deleted"+mwwFileToBeDeleted .delete()); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload