misc. fixes
[mir.git] / source / mir / util / ExecFunctions.java
index bc6d864..34ce35d 100755 (executable)
@@ -34,18 +34,15 @@ import java.io.IOException;
 
 /**
  * Execute system commands. Warning: the current implementation is
- * unix specific. 
+ * unix specific.
  */
-public class ExecFunctions
-{
+public class ExecFunctions {
   /**
    * Executes a full command (including arguments) in a subshell
    * and returns the output of the command in a string. Output is
    * redirected into a temporary fil which is then read into the string
    */
-  public static String execIntoString(String command)
-    throws IOException
-  {
+  public static String execIntoString(String command) throws IOException {
     return new String(execIntoByteArray(command));
   }
 
@@ -55,27 +52,25 @@ public class ExecFunctions
    * bytes. Output is redirected into a temporary file which is then
    * read into an array of bytes
    */
-  public static byte[] execIntoByteArray(String command)
-    throws IOException
-  {
-    File commandOutput=File.createTempFile("mircmd","");
+  public static byte[] execIntoByteArray(String command) throws IOException {
+    File commandOutput = File.createTempFile("mircmd", "");
     int exitStatus;
-    try
-    {
+    try {
       // WARNING: unix specific
-      exitStatus=Runtime.getRuntime().exec(new String[]{
-        "/bin/sh","-c",
-        command+" "+
-        ">"+commandOutput.getAbsolutePath()
+      exitStatus = Runtime.getRuntime().exec(new String[]{
+        "/bin/sh", "-c",
+        command + " " +
+          ">" + commandOutput.getAbsolutePath()
       }).waitFor();
     }
-    catch(InterruptedException e){ throw new IOException(e.toString());}
-    if(exitStatus!=0)
-    {
-        throw new IOException("command exit satus:"+exitStatus);
+    catch (InterruptedException e) {
+      throw new IOException(e.toString());
     }
-    byte [] result = FileRoutines.readFileIntoByteArray
-      (commandOutput.getAbsolutePath());
+    if (exitStatus != 0) {
+      throw new IOException("command exit satus:" + exitStatus);
+    }
+    byte[] result = FileRoutines.readFileIntoByteArray
+        (commandOutput.getAbsolutePath());
     commandOutput.delete();
     return result;
   }
@@ -85,22 +80,21 @@ public class ExecFunctions
    * Standard input and output go to /dev/null
    */
   public static void simpleExec(String command)
-    throws IOException
-  {
+      throws IOException {
     int exitStatus;
-    try
-    {
+    try {
       // WARNING: unix specific
-      exitStatus=Runtime.getRuntime().exec(new String[]{
-        "/bin/sh","-c",
-        command+" "+">/dev/null 2>/dev/null"
+      exitStatus = Runtime.getRuntime().exec(new String[]{
+        "/bin/sh", "-c",
+        command + " " + ">/dev/null 2>/dev/null"
       }).waitFor();
     }
-    catch(InterruptedException e){ throw new IOException(e.toString());}
-    if(exitStatus!=0)
-    {
-        throw new IOException("command exit satus:"+exitStatus);
+    catch (InterruptedException e) {
+      throw new IOException(e.toString());
+    }
+    if (exitStatus != 0) {
+      throw new IOException("command exit satus:" + exitStatus);
     }
   }
-  
+
 }