diff options
Diffstat (limited to 'app/src/fil/libre/repwifiapp/helpers/ShellCommand.java')
-rw-r--r-- | app/src/fil/libre/repwifiapp/helpers/ShellCommand.java | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/app/src/fil/libre/repwifiapp/helpers/ShellCommand.java b/app/src/fil/libre/repwifiapp/helpers/ShellCommand.java index fbeb719..f232ac7 100644 --- a/app/src/fil/libre/repwifiapp/helpers/ShellCommand.java +++ b/app/src/fil/libre/repwifiapp/helpers/ShellCommand.java @@ -5,6 +5,8 @@ import java.io.InputStream; public class ShellCommand { + public static final int EXITCODE_INVALID_INPUT = -9; + protected String _cmdOut = ""; protected String _cmdTxt = ""; @@ -15,12 +17,13 @@ public class ShellCommand { public int execute() throws Exception { if (this._cmdTxt == null) { - return -9; + return EXITCODE_INVALID_INPUT; } Utils.logDebug("EXEC: " + this._cmdTxt); Process cmd = Runtime.getRuntime().exec(this._cmdTxt); + InputStream os = cmd.getInputStream(); InputStream es = cmd.getErrorStream(); @@ -47,6 +50,11 @@ public class ShellCommand { protected String getStringFromStream(InputStream s) throws IOException { + java.util.Scanner sc = new java.util.Scanner(s,"UTF-8").useDelimiter("\\A"); + return sc.hasNext() ? sc.next() : ""; + + /* + StringBuilder sb = new StringBuilder(); while ((s.available() > 0)) { int b = s.read(); @@ -57,7 +65,7 @@ public class ShellCommand { } } - return sb.toString(); + return sb.toString();*/ } @@ -65,17 +73,6 @@ public class ShellCommand { return this._cmdOut; - /* - * String[] lastOut = Utils.readFileLines(Commons.getTempOutFile()); if - * (lastOut == null){ return this._cmdOut; } - * - * String fout = ""; - * - * for (String s : lastOut){ fout += s + "\n"; } - * - * return fout; - */ - } } |