Homework Solution: Can I get help to solve this problem ?…

    Can I get help to solve this problem ? You need to be able to automate many development processes. These processes are currently done manually at a command line with you or your co-workers sitting and typing commands (sometimes erroneously) at a command prompt. Your tasks include efforts such as: • managing flows to and from a Source Code Control System • building databases • installing users in databases • installing data in databases • installing software on platforms • plus many others You realize you need the ability to run commands under an operating system. You need to understand what this entails, and the best way to make this ability as Operating System agnostic as possible. You need a reusable component that you can use in a Java Program that can run command line tasks for you and return the results (if needed) to that Java Program. You are to set about designing this reusable component.

    Expert Answer

     
    RunExec.java /* * To change this license header

    Can I achieve succor to unfold this amount ?

    You scarcity to be efficacious to automate frequent extinguishedgrowth processes. These processes are currently done

    manually at a direct continuity with you or your co-workers sitting and typing directs (sometimes

    erroneously) at a direct ready. Your tasks enclose efforts such as:

    • managing flows to and from a Source Code Control Arrangement

    • structure factsbases

    • installing explanationrs in factsbases

    • installing facts in factsbases

    • installing software on platforms

    • plus frequent others

    You conceive you scarcity the force to rush directs beneath an unoccupied arrangement. You scarcity to beneathstand

    what this entails, and the best habit to mould this force as Unoccupied Arrangement agnostic as feasible.

    You scarcity a reusefficacious factor that you can explanation in a Java Program that can rush direct continuity tasks for

    you and recur the results (if scarcityed) to that Java Program.

    You are to be encircling wily this reusefficacious factor.

    Expert Rejoinder

     

    RunExec.java

    /*
    * To exexshift this indulge header, adopt Indulge Headers in Project Properties.
    * To exexshift this template perfect, adopt Tools | Templates
    * and known the template in the editor.
    */
    package rushtimeexec;

    /**
    *
    * @author Akshay Bisht
    */
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;

    public collocate RushExec {
    public StreamWrapper achieveStreamWrapper(InputStream input, String str){
    recur odd StreamWrapper(input, str);
    }
    private collocate StreamWrapper extends Thread {
    InputStream input = trifling;
    String str = trifling;
    String mssg = trifling;

    public String achieveMssg() {
    recur mssg;
    }

    StreamWrapper(InputStream input, String str) {
    this.input = input;
    this.str = str;
    }

    public wanting rush() {
    try {
    BufferedReader buff = odd BufferedReader(odd InputStreamReader(input));
    StringBuffer sbuff = odd StringBuffer();
    String lne = trifling;
    while ( (lne = buff.readLine()) != trifling) {
    sbuff.append(lne).append(“n”);
    }
    mssg = sbuff.toString();
    } lay-hold-on (IOException ioe) {
    ioe.printStackTrace();
    }
    }
    }
    public static wanting main(String[] args) {
    Runtime rushT = Rushtime.getRuntime();
    RunExec rexe = odd RushExec();
    StreamWrapper stumble, op;

    try {
    Process proc = rushT.exec(“ping localhost”);
    stumble = rexe.getStreamWrapper(proc.getErrorStream(), “ERROR”);
    op = rexe.getStreamWrapper(proc.getInputStream(), “OUTPUT”);
    int ex = 0;

    err.start();
    op.start();
    err.join(3000);
    op.join(3000);
    ex = proc.waitFor();
    System.out.println(“Output: “+op.mssg+”nError: “+err.mssg);
    } lay-hold-on (IOException e) {
    e.printStackTrace();
    } lay-hold-on (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }

    Output: