Java 8 ProcessBuilder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ProcessBuilder class.

This code example shows how to use the following methods:start
		ProcessBuilder pb = null;
		String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
		if (os.indexOf("win") >= 0) { //$NON-NLS-1$
			pb = new ProcessBuilder("cmd", "/c", WIN_SCRIPT + " " + STD_LIB);    //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
		} else if (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0) { //$NON-NLS-1$ //$NON-NLS-2$
			pb = new ProcessBuilder("bash", "-c", UNIX_SCRIPT);    //$NON-NLS-1$//$NON-NLS-2$
		} else if (os.indexOf( "mac" ) >= 0) { //$NON-NLS-1$
			pb = new ProcessBuilder("bash", "-c", MAC_SCRIPT);    //$NON-NLS-1$//$NON-NLS-2$
		} else { 
			return null; 
		} 
		try { 
			Process p = pb.start();
			String line;
			BufferedReader input = new BufferedReader
					(new InputStreamReader(p.getInputStream()));
			line = input.readLine();
			input.close();
			if (line != null) {
				return line;
5
CodeRank
This code example shows how to use the following methods:
 
    private void chmod(String... args) throws IOException {
        String[] cmdline = new String[args.length + 1];
        cmdline[0] = "/system/bin/chmod";
        System.arraycopy(args, 0, cmdline, 1, args.length);
        new ProcessBuilder(cmdline).start();
    } 
} 
5
CodeRank

Related Java 8 ProcessBuilder Questions & Answers:

See Code Examples for Java 8 ProcessBuilder Methods: