pipe-io-server/clients/java/PipeWriter.java
2019-04-09 14:54:43 +02:00

23 lines
552 B
Java

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();
}
}