Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Removing a lock file.

807607Dec 21 2006 — edited Jan 3 2007
Here is my code, I can't get the lockFile to delete, any ideas?

FILE 1
  public static final File lockFile = new File("c:/fileLock"); 
    public static FileLock lock = null;

    public void aR()
    {
        try
        {
            FileChannel channel = new RandomAccessFile(lockFile, "rw").
                                  getChannel();
            try
            {
                lock = channel.tryLock();
                if (lock == null)
                {
                    System.exit(0);
                }
            } catch (OverlappingFileLockException e)
            {
            }
        } catch (Exception e)
        {
        }
    }
FILE 2
  public void clean()     {
        try
        {
            manager.lock.release();
        } catch (IOException ioe)
        {}
        manager.lockFile.delete();
    }
Message was edited by:
javarob
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 31 2007
Added on Dec 21 2006
4 comments
382 views