Linked Questions
70 questions linked to/from How can I lock a file using Java?
5 votes
4 answers
27k views
Java: how to handle two process trying to modify the same file [duplicate]
Possible Duplicate: How can I lock a file using java (if possible) I have two process that invoke two Java programs that modifying the same text file. I notice the content of the text file is ...
5 votes
1 answer
5k views
How to lock a file in linux/unix by a java program? [duplicate]
I need to lock a file in unix/linux OS. I have googled and read about java.nio.channels Filelock and Reentrant File Lock . But both works in Windows but not in unix. Is there any other way of ...
0 votes
1 answer
4k views
How to create interprocess file access mutex in java? [duplicate]
I have two processes reading/writing same files. So I wanna create a lock between them. My idea is to create a file in that folder named file.lock containing the process identification information. ...
2 votes
2 answers
1k views
Lock file for writing? [duplicate]
Possible Duplicate: How can I lock a file using java (if possible) Is it possible to lock file so that other apps cannot write to file but can still run it normally? My target platform is windows.
-1 votes
1 answer
964 views
Java file lock for read and write with multiple processes [duplicate]
In my application multiple processes are trying access a file for read and write. Every application has a single thread. I need to make sure that no 2 processes are accessing the file at the same time....
1 vote
1 answer
468 views
Java : How to block other program from accessing file if one program is using it? [duplicate]
I have 2-3 programs which can modify file but I want to block others if one program is using it. I cant use synchronization in this. Is there any other provision ?
0 votes
1 answer
427 views
Concurrent read and write from different programs in Java [duplicate]
I'm writing two programs that communicate through a text file. The first program writes to the file and the second one reads from it. However, there is a problem when the reader program tries to read ...
0 votes
1 answer
139 views
How to lock a file then clear its contents? [duplicate]
How can i lock a file then clear its contents and write to it? Clearing a file can be as simple as: FileOutputStream fos = new FileOutputStream(someFileObject); And acquiring the lock would be by: ...
0 votes
1 answer
106 views
how to implement File Locking in java 6 for both windows and linux [duplicate]
In my project, i need to imeplement file locking and the problem is that we need to use java 6 only so what are the ways through which i can implement file locking for both platform(windows/linux)
1 vote
0 answers
52 views
How to lock document files? [duplicate]
Is there any way to lock files of these types: txt pdf docx doc If locked, it should not be possible to edit, copy or print it.
437 votes
23 answers
378k views
How can a Java program get its own process ID?
How do I get the id of my Java process? I know there are several platform-dependent hacks, but I would prefer a more generic solution.
26 votes
6 answers
55k views
Checking if file is completely written [duplicate]
Currently I'm working on the project that does processing files from source directory in one of it's routines. There's a Java process that's looking for specified directory and tries to read and ...
17 votes
8 answers
27k views
Start Java program only if not already running
I need to start 1-3 external programs in my Java application that have paths defined by the user. I have few requirements: I don't want the program to execute if it is already running I don't want ...
23 votes
3 answers
42k views
Java FileLock for Reading and Writing
I have a process that will be called rather frequently from cron to read a file that has certain move related commands in it. My process needs to read and write to this data file - and keep it locked ...
12 votes
5 answers
41k views
How to create and lock a file for writing only if it does not exist [duplicate]
I'm trying to implement the following operation in Java and am not sure how: /* * write data (Data is defined in my package) * to a file only if it does not exist, return success */ boolean ...