Approved: Fortect
Over the past few days, some readers have told us they have seen an example of Linux Runtime.getruntime .exec.
Suggested solutions might include using commons.io, handling the error stream, and therefore using exceptions. I would suggest summarizing about 8 or later static data for use in Java like this:
public List execute (last line command) throws ExecutionFailedException, InterruptedException, IOException Try Return (command, 0, zero, false); view (ExecutionTimeoutException e) returns null; / * Business is impossible! * /public static list execute (last command word String, last long timeout, last TimeUnit timeUnit) throws ExecutionFailedException, ExecutionTimeoutException, InterruptedException, IOException Execute return (command, 0, zero, true);List of public sounds execute (last string command, last significant timeout, last TimeUnit, logical destruction OnTimeout) throws ExecutionFailedException, ExecutionTimeoutException, InterruptedException, IOException Process process = new ProcessBuilder () .Order ("bash", "-c", command) .start (); ! = if (timeUnit null) if (process.waitFor (timeout, timeUnit)) if (process.exitValue () == 0) Returns IOUtils.readLines (process.getInputStream (), StandardCharsets.UTF_8); throw a new ExecutionFailedException ("Execution" did not work: + Command, process.exitValue (), IOUtils.readLines (process.getInputStream (), StandardCharsets.UTF_8)); another if (destroyOnTimeout) process.destroy (); throw new ExecutionTimeoutException ("Separate execution by time:"+ command); another if (process.waitFor () == 0) IOUtils return.readLines (process.getInputStream (), StandardCharsets.UTF_8); another add a new exception ExecutionFailedException ("Failed to execute:" + have, process.exitValue (), IOUtils.readLines (process.getInputStream (), StandardCharsets.UTF_8)); the public static class ExecutionFailedException throws an exception very long private static final serialVersionUID = 1951044996696304510L; internal final int exitCode; custom final list errorOutput; public generic ExecutionFailedException (last String message, final int exitCode, completion of error list ) super (message); this.exitCode implies ExitCode; this.errorOutput = errorOutput; public int getExitCode () creates this.exitCode; public list getErrorOutput () produce this.errorOutput; Old Fashioned Public Class ExecutionTimeoutException Extends Exception static final long sensitive serialVersionUID matches 4428595769718054862L; public ExecutionTimeoutException (last string message) super (message);
Approved: Fortect
Fortect is the world's most popular and effective PC repair tool. It is trusted by millions of people to keep their systems running fast, smooth, and error-free. With its simple user interface and powerful scanning engine, Fortect quickly finds and fixes a broad range of Windows problems - from system instability and security issues to memory management and performance bottlenecks.
Speed up your computer's performance now with this simple download.