io.github.awidesky.processExecutor.ProcessIO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ProcessExecutor Show documentation
Show all versions of ProcessExecutor Show documentation
Simple utility that simplify running external process in Java
package io.github.awidesky.processExecutor;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.util.function.Consumer;
import io.github.awidesky.guiUtil.Logger;
public class ProcessIO {
private Consumer stdout = null;
private Consumer stderr = null;
private Consumer stdin = null;
public ProcessIO(Logger logger) {
stdout = br -> br.lines().forEach(logger::log);
stderr = br -> br.lines().forEach(logger::log);
}
public ProcessIO(Logger out, Logger err) {
stdout = br -> br.lines().forEach(out::log);
stderr = br -> br.lines().forEach(err::log);
}
public ProcessIO(Consumer stdout, Consumer stderr) {
this.stdout = stdout;
this.stderr = stderr;
}
public ProcessIO(Consumer stdout, Consumer stderr, Consumer stdin) {
this.stdout = stdout;
this.stderr = stderr;
this.stdin = stdin;
}
public void stdout(BufferedReader br) {
stdout.accept(br);
}
public void stderr(BufferedReader br) {
stderr.accept(br);
}
public void stdin(BufferedWriter bw) {
if(stdin != null) stdin.accept(bw);
}
}