Package com.sun.mail.util
Class TimeoutOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.sun.mail.util.TimeoutOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
class TimeoutOutputStream extends java.io.OutputStreamAn OutputStream that wraps the Socket's OutputStream and uses the ScheduledExecutorService to schedule a task to close the socket (aborting the write) if the timeout expires.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]b1private java.io.OutputStreamosprivate java.util.concurrent.ScheduledExecutorServicesesprivate inttimeoutprivate java.util.concurrent.Callable<java.lang.Object>timeoutTask
-
Constructor Summary
Constructors Constructor Description TimeoutOutputStream(java.io.OutputStream os0, java.util.concurrent.ScheduledExecutorService ses, int timeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidwrite(byte[] bs, int off, int len)voidwrite(int b)
-
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] bs, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
-