keshari Posted June 4, 2008 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(); }} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.