how about this.
Make another file called flag.txt
set the text of flag.txt text to "1" when the program is creating it,
then set the flag.txt text to "0" when it is done creating it.
Before process B reads the file, check its associated flag.
you can create many flag.txt files, you could simply use the
strNameOfTheFile + "flag.txt" as the unique flag.txt documents per
file.
let me know how it goes for you.
Eric Sosman wrote:
> wrote On 08/01/06 10:06,:
> > Dear all,
> >
> > I wonder if anyone of you guys out there could help me out with this:
> >
> > I want to read a file, but only want to do that when another process
> > that is creating it is done creating it. Say it is an (external)
> > process A that creates the file and my process B that reads the file. I
> > want to somehow verify that when an attempt is made by B to read that
> > particular file in the file system, the file is not currently being
> > written to by process A.
> >
> > A ----> writes ---> file <--- reads ---- B
> >
> > Is there any way to do this in Java?
>
> Not that I know of. One technique that's often used
> is to have A write to "output.tmp", say, and rename it to
> "output.dat" when it has finished all its writing. That
> way, B cannot even find the "output.dat" file while A is
> still writing it.
>
> --
>