Package gov.usgs.earthquake.util
Class TimeoutOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- gov.usgs.earthquake.util.TimeoutOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
,java.lang.Runnable
public class TimeoutOutputStream extends java.io.FilterOutputStream implements java.lang.Runnable
An output stream that self-closes if the specified timeout elapses between writes.
-
-
Constructor Summary
Constructors Constructor Description TimeoutOutputStream(java.io.OutputStream out, long timeout)
Create a TimeoutOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
run()
void
write(byte[] buf)
void
write(byte[] buf, int offset, int length)
void
write(int b)
-
-
-
Constructor Detail
-
TimeoutOutputStream
public TimeoutOutputStream(java.io.OutputStream out, long timeout)
Create a TimeoutOutputStream.- Parameters:
out
- the wrapped output stream.timeout
- the timeout in milliseconds between writes. If this timeout completes, the underlying stream will be closed.
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] buf) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int offset, int length) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
-