import java.io.IOException; public class PipeIO implements AutoCloseable { protected PipeReader reader; protected PipeWriter writer; public PipeIO(String in_pipe_path, String out_pipe_path) throws IOException { this.reader = new PipeReader(in_pipe_path); this.writer = new PipeWriter(out_pipe_path); } public void close() throws IOException { this.reader.close(); this.writer.close(); } public void run() throws IOException { String msg; while ((msg = this.reader.recvMessage()) != null) { this.handleMessage(msg); } } public void handleMessage(String msg) throws IOException {} }