import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.lang.AutoCloseable; public class PipeWriter implements AutoCloseable { private BufferedWriter pipe; public PipeWriter(String pipe_path) throws IOException { this.pipe = new BufferedWriter(new FileWriter(pipe_path)); } public void close() throws IOException { this.pipe.close(); } public void sendMessage(String msg) throws IOException { this.pipe.write(msg + "\n"); this.pipe.flush(); } }