ProcessBuilder.command(List < String > command) has the following syntax.
public ProcessBuilder command(List <String> command)
In the following code shows how to use ProcessBuilder.command(List < String > command) method.
/* ww w . j a v a2 s .c om*/ import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { List<String> list = new ArrayList<String>(); list.add("notepad.exe"); ProcessBuilder pb = new ProcessBuilder(list); List<String> list2 = new ArrayList<String> (); list2.add("text.txt"); // set the command list pb.command(list2); System.out.println(pb.command()); } }
The code above generates the following result.