#If JAVA
import java.io.BufferedReader;
import java.io.InputStreamReader;
//Execute a command AND capture the output In a String
//Parameter: Command To run
//Returns: String with the command output
//Example:
//Dim cmd as String = "ls"
//Dim result As String = Main.joInlineJava.RunMethod("ExecuteCommand", Array(cmd))
public static String ExecuteCommand(String command) {
StringBuffer output = new StringBuffer();
Process p;
try
{
p = Runtime.getRuntime().exec(command);
p.waitFor();
BufferedReader reader =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null)
{
output.append(line + "\n");
}
}
catch (Exception e)
{
//e.printStackTrace();
return "Error executing command " + command;
}
//System.out.println(output);
return output.toString();
}
#End If