There is an external program that creates an XML file, but it may take a while to create. I need my Java program to wait until the file exists before moving on.
I've been reading up a little bit about synchronized blocks, and I read that I can do something like this:
synchronized(this) {
while (!file.exists) { this.wait(); }
}
To be honest I don't really know much about synchronized tasks so I'm wondering if I'm on the right track, or if I'm way off.
A typical way to solve this problem is for your XML writer to create the XML file, and when it it is done, it should create a second file saying the work is done.
Your java program should listen for the existence of the .done file rather than the XML file.
Won't work if you don't have any control over the XML writing application, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With