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 earn acceleration to clear-up this amount ?

    You want to be cogent to automate manifold crop processes. These processes are currently done

    manually at a bid thread with you or your co-workers sitting and typing bids (sometimes

    erroneously) at a bid active. Your tasks embrace efforts such as:

    • managing flows to and from a Source Code Control Rankification

    • construction groundsbases

    • installing verificationrs in groundsbases

    • installing grounds in groundsbases

    • installing software on platforms

    • plus manifold others

    You exhibit you want the force to leak bids lower an unimpeded rankification. You want to lowerstand

    what this entails, and the best habit to gain this force as Unimpeded Rankification agnostic as feasible.

    You want a reuscogent rudiment that you can verification in a Java Program that can leak bid thread tasks for

    you and come-back the results (if wanted) to that Java Program.

    You are to be abextinguished crafty this reuscogent rudiment.

    Expert Response

     

    RunExec.java

    /*
    * To substitute this permit header, cull Permit Headers in Project Properties.
    * To substitute this template refine, cull Tools | Templates
    * and unconcealed the template in the editor.
    */
    package leaktimeexec;

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

    public rank LeakExec {
    public StreamWrapper earnStreamWrapper(InputStream input, String str){
    come-back novel StreamWrapper(input, str);
    }
    private rank StreamWrapper extends Thread {
    InputStream input = trifling;
    String str = trifling;
    String mssg = trifling;

    public String earnMssg() {
    come-back mssg;
    }

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

    public bereft leak() {
    try {
    BufferedReader buff = novel BufferedReader(novel InputStreamReader(input));
    StringBuffer sbuff = novel StringBuffer();
    String lne = trifling;
    while ( (lne = buff.readLine()) != trifling) {
    sbuff.append(lne).append(“n”);
    }
    mssg = sbuff.toString();
    } grasp (IOException ioe) {
    ioe.printStackTrace();
    }
    }
    }
    public static bereft main(String[] args) {
    Runtime leakT = Leaktime.getRuntime();
    RunExec rexe = novel LeakExec();
    StreamWrapper stray, op;

    try {
    Process proc = leakT.exec(“ping localhost”);
    stray = 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);
    } grasp (IOException e) {
    e.printStackTrace();
    } grasp (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }

    Output: