aspose file tools*
The moose likes Beginning Java and the fly likes who can my question about this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "who can my question about this code" Watch "who can my question about this code" New topic
Author

who can my question about this code

lei feng
Greenhorn

Joined: Aug 23, 2007
Posts: 26
lei feng
Greenhorn

Joined: Aug 23, 2007
Posts: 26
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!
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
lei feng
Greenhorn

Joined: Aug 23, 2007
Posts: 26
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
lei feng
Greenhorn

Joined: Aug 23, 2007
Posts: 26
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: who can my question about this code