keshari 0 Posted June 4, 2008 Report Share Posted June 4, 2008 Hi AllMy current code is executing system commands through java programme,like “dir”,”date” itc.Whenever I run the code the desired output comes.But when I am running the code continuselly then lots of command prompt open regularlly.Is there any way to stop the code from execution untill unless the command prompt get closed manually?Here is my code.import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.IOException;interface IPerlService{ public String BZMCreateZone(String s); public int BZMRenew();}public class Sample { public void BZMCreateZone() { Runtime runtime; Process process; String s=null; String str=null; try { runtime = Runtime.getRuntime(); process =runtime.exec("cmd /c start dir"); str=process.toString(); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream())); s = reader.readLine(); } catch (IOException ex) { ex.printStackTrace(); } } public static void main(String[] args) { Sample obj_Sample= new Sample(); obj_Sample.BZMCreateZone(); }} Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.