Skip to content

Instantly share code, notes, and snippets.

@TheNotary
Created April 6, 2013 19:12
Show Gist options
  • Save TheNotary/5327254 to your computer and use it in GitHub Desktop.
Save TheNotary/5327254 to your computer and use it in GitHub Desktop.
plugins/com.aptana.editor.ruby/src/org/eclipse/ui/texteditor/MyGemFunctions.java
public static String getGemsDirectory()
{
try
{
Process proc = Runtime.getRuntime().exec("which ruby");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
String s;
String commandOutput = "";
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
//System.out.println(s);
commandOutput += s;
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((String s = stdError.readLine()) != null) {
//System.out.println(s);
commandOutput += s;
}
int statusCode = proc.exitValue();
return commandOutput;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
return "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment