-
Notifications
You must be signed in to change notification settings - Fork 826
Expand file tree
/
Copy pathShellCommand.java
More file actions
executable file
·41 lines (33 loc) · 1.14 KB
/
ShellCommand.java
File metadata and controls
executable file
·41 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.github.hiteshsondhi88.libffmpeg;
import java.io.IOException;
class ShellCommand {
Process run(String[] commandString) {
Process process = null;
try {
process = Runtime.getRuntime().exec(commandString);
} catch (IOException e) {
Log.e("Exception while trying to run: " + commandString, e);
}
return process;
}
CommandResult runWaitFor(String[] s) {
Process process = run(s);
Integer exitValue = null;
String output = null;
try {
if (process != null) {
exitValue = process.waitFor();
if (CommandResult.success(exitValue)) {
output = Util.convertInputStreamToString(process.getInputStream());
} else {
output = Util.convertInputStreamToString(process.getErrorStream());
}
}
} catch (InterruptedException e) {
Log.e("Interrupt exception", e);
} finally {
Util.destroyProcess(process);
}
return new CommandResult(CommandResult.success(exitValue), output);
}
}