Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.BufferedWriter;

import java.io.OutputStreamWriter;

public class Main {
    public static Process execute(String command) throws Exception {
        final Process process = new ProcessBuilder("sh").redirectErrorStream(true).start();

        BufferedWriter stdOutput = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));

        stdOutput.write(command + "; exit\n");
        stdOutput.flush();
        stdOutput.close();

        return process;
    }
}