• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Checking for File Open or Closed state

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am working on project that requires checking to see if a file is open or closed. The application takes the information in the file on one system and places it on another system to modify. I have tried setting up a file lock so that I can lock the file using the FileChannel and FileLock api's. I am in a windows environment. When I test the program with the file already open in notepad, the program is still able to get a lock on the file even though I expect it not to be able to. The only time it fails is if I run another java thread that attempts to get the lock for the same file. However, it does not seem to work if a another user has it "open" using some type of editor.
Is there anyway at all to check to see if the file is open or closed and gain exclusive access to that file? For example, a user is editing the file using Microsoft Word, and my java application needs exclusive access to that file needs to check if it is open period. For the purposes of this project, there is highly sensitive information that needs to be transferred, and it can not be being edited by an outside application while the application is moving the file. Any guidance would be appreciated.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ron Yorrick:
When I test the program with the file already open in notepad, the program is still able to get a lock on the file even though I expect it not to be able to.


Note Pad does not lock the file. The same is true with Wordpad.

MS Word does however lock the file.

Joe
 
reply
    Bookmark Topic Watch Topic
  • New Topic