aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/e1/pdj/ConsoleStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/e1/pdj/ConsoleStream.java')
-rw-r--r--src/java/com/e1/pdj/ConsoleStream.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/java/com/e1/pdj/ConsoleStream.java b/src/java/com/e1/pdj/ConsoleStream.java
new file mode 100644
index 0000000..cf396c7
--- /dev/null
+++ b/src/java/com/e1/pdj/ConsoleStream.java
@@ -0,0 +1,35 @@
+package com.e1.pdj;
+
+import java.io.*;
+
+import com.cycling74.max.MaxSystem;
+
+public class ConsoleStream extends OutputStream {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream(4096);
+
+ protected void send(String message) {
+ MaxSystem.post("pdj: " + message);
+ }
+
+ public void flush() {
+ String msg = buffer.toString();
+ if ( msg.endsWith("\n") ) {
+ msg = msg.substring(0, msg.length()-1);
+ }
+ if ( !msg.equals("") )
+ send(buffer.toString());
+ buffer.reset();
+ }
+
+ public void write(byte[] b) throws IOException {
+ buffer.write(b);
+ }
+
+ public void write(int b) throws IOException {
+ buffer.write(b);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ buffer.write(b, off, len);
+ }
+}