KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > ProcessBuilder

java.lang
Class ProcessBuilder

java.lang.Object
  extended by java.lang.ProcessBuilder
See Also:
Map.clear(), Process.getErrorStream(), Process.getInputStream(), System.getenv(), start()

public List<String> command()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ProcessBuilder command(String... command)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ProcessBuilder command(List<String> command)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public File directory()
See Also:
start()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1808]Set a starting directory for executing an external program
By Anonymous on 2006/08/23 12:21:13  Rate
import java.io.*; 
 import java.util.*; 
  
  
 public class CmdProcessBuilder  {  
 public static void main ( String args [  ]  )  throws InterruptedException,IOException  {  
 List command = new ArrayList (  ) ; 
 command.add ( System.getenv ( "windir" )  +"\\system32\\"+"tree.com" ) ; 
 command.add ( "/A" ) ; 
  
  
 ProcessBuilder builder = new ProcessBuilder ( command ) ; 
 Map environ = builder.environment (  ) ; 
 builder.directory (  
   new File ( System.getenv ( "temp" )  )  ) ; 
  
  
 System.out.println ( "Directory : " + System.getenv ( "temp" )   ) ; 
 final Process process = builder.start (  ) ; 
 InputStream is = process.getInputStream (  ) ; 
 InputStreamReader isr = new InputStreamReader ( is ) ; 
 BufferedReader br = new BufferedReader ( isr ) ; 
 String line; 
  
  
 while  (  ( line = br.readLine (  )  )  != null )   {  
   System.out.println ( line ) ; 
  }  
  
  
 System.out.println ( "Program terminated!" ) ; 
  }  
  }  
 


public ProcessBuilder directory(File directory)
See Also:
start()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Map<String,String> environment()
See Also:
System.getenv(), Runtime.exec(String[],String[],java.io.File), checkPermission, SecurityException, RuntimePermission, Object.hashCode(), Object.equals(java.lang.Object), IllegalArgumentException, UnsupportedOperationException, ClassCastException, NullPointerException, System.getenv, start()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ProcessBuilder(String... command)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ProcessBuilder(List<String> command)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean redirectErrorStream()
See Also:
Process.getInputStream(), start()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ProcessBuilder redirectErrorStream(boolean redirectErrorStream)
See Also:
Process.getInputStream(), start()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Process start()
              throws IOException
See Also:
SecurityManager.checkExec(String), Runtime.exec(String[], String[], java.io.File), SecurityException, IndexOutOfBoundsException, NullPointerException, environment(), directory(), command()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags