Java Shell Command runCommandArray(String[] command)

Here you can find the source of runCommandArray(String[] command)

Description

Run curl command

License

Apache License

Parameter

Parameter Description
command a parameter

Declaration

public static void runCommandArray(String[] command) 

Method Source Code


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

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    /***/*from  w w w  .j  ava2s . co  m*/
    * Run curl command
    * @param command
    */
    public static void runCommandArray(String[] command) {
        Process p = null;
        try {
            p = Runtime.getRuntime().exec(command);
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line = null;
        try {
            while ((line = input.readLine()) != null)
                System.out.println(line);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            p.waitFor();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

Related

  1. runCommand(String[] args)
  2. runCommand(String[] cmdArray, String extraPath, String libPath)
  3. runCommand(String[] command)
  4. runCommand(String[] command)
  5. runCommandAndWait(String command, String workingDir, String extraPath)
  6. runCommandGetOutput(String startFolder, String[] args, int[] cmdReturnValue)
  7. runCommandPrompt(final String commandLine, final IPath path)
  8. runCommandWithOutput(String cmd)
  9. runShell(File workspace, String... shellElements)