This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
1. if i only use process.waitFor(), the whole program will wait forever and never wake up and return. 2. but using this code the program only wait for the file have been moved. then run the next code? i don't know why? 3. the StreamGobbler as a thread. what is its function? i suppose this thread is why the waitFor() can return..but i don't know how does it get it?
who can answer me....thanks any help will be appreciate!
The StreamGobbler threads read the stdout and errout of the command. They are on separate threads because we don't know when either or both of those streams will have data, if they ever do.
I'm not sure where you got StreamGobbler; there are several versions around the net. Does it display what it reads right away? Or store it up for later? Check and see if you are getting any messages from the command.
Does that whole command execute ok from a command window? Including the cmd.exe /C part?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Aug 23, 2007
thanks you reply.I still want to figure out how it works to ensure when the proccess wait until the cmd finish. if i use move xxx xxx this cmd i don't get any message. but i try to use the dir cmd, i get the whole information from the cmd to the eclipse console...I'm going to check the code
Joined: Aug 23, 2007
I get it the answer. see the different result:
use this code, the process will wait until you stop it manually
this code will stop after the cmd finsh task.
the reason: use getRuntime.exec() will get a inpustream,if you don't read this inputstream in time. the process will lock. if you use waitFor() the whole process will lock,so you must read(clear) the inputstream to esure the process run.