Java exec executeCommand(String command)

Here you can find the source of executeCommand(String command)

Description

execute Command

License

Apache License

Declaration

public static String executeCommand(String command) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;

import java.util.Scanner;

public class Main {
    public static String executeCommand(String command) throws IOException {
        Process proc = Runtime.getRuntime().exec(command);
        try (InputStream stream = proc.getInputStream()) {
            try (Scanner s = new Scanner(stream).useDelimiter("\\A")) {
                return s.hasNext() ? s.next() : "";
            }/*from www  .j a v a 2s. c  o m*/
        }
    }
}

Related

  1. executeCommand(String comand)
  2. executeCommand(String command)
  3. executeCommand(String command)
  4. executeCommand(String command)
  5. executeCommand(String command)
  6. executeCommand(String command)
  7. executeCommand(String command, boolean waitForResponse)
  8. executeCommand(String[] command, boolean wait)
  9. executeCommand1(boolean isProcessBuilder, String command)