All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.awidesky.processExecutor.ProcessIO Maven / Gradle / Ivy

There is a newer version: 0.0.34
Show newest version
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);
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy