Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save anandadake/72637a5e1cbf93148582f97c0b7314a6 to your computer and use it in GitHub Desktop.

Select an option

Save anandadake/72637a5e1cbf93148582f97c0b7314a6 to your computer and use it in GitHub Desktop.
Execute Command in Cmd

Implemenation to execute Command in CMD with java

public String execCmd(String cmd) throws java.io.IOException {
        java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\A");
        return s.hasNext() ? s.next() : "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment