2013-11-14 07:17:51 +00:00
|
|
|
package com.ryanmichela.sshd;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copyright 2013 Ryan Michela
|
|
|
|
*/
|
|
|
|
public class FlushyOutputStream extends OutputStream {
|
|
|
|
private OutputStream base;
|
2018-03-25 16:47:35 +00:00
|
|
|
private boolean isClosed = false;
|
2013-11-14 07:17:51 +00:00
|
|
|
|
|
|
|
public FlushyOutputStream(OutputStream base) {
|
|
|
|
this.base = base;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(int b) throws IOException {
|
2018-03-25 16:47:35 +00:00
|
|
|
if(isClosed) return;
|
2013-11-14 07:17:51 +00:00
|
|
|
base.write(b);
|
|
|
|
base.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(byte[] b) throws IOException {
|
2018-03-25 16:47:35 +00:00
|
|
|
if(isClosed) return;
|
2013-11-14 07:17:51 +00:00
|
|
|
base.write(b);
|
|
|
|
base.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(byte[] b, int off, int len) throws IOException {
|
2018-03-25 16:47:35 +00:00
|
|
|
if(isClosed) return;
|
2013-11-14 07:17:51 +00:00
|
|
|
base.write(b, off, len);
|
|
|
|
base.flush();
|
|
|
|
}
|
2018-03-25 16:47:35 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void close() {
|
|
|
|
isClosed = true;
|
|
|
|
}
|
2013-11-14 07:17:51 +00:00
|
|
|
}
|