anon.util
Class TimedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by anon.util.TimedOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public final class TimedOutputStream
extends java.io.OutputStream

This class implements an OutputStream, where a timeout for the write() and flush () operations can be set.


Nested Class Summary
private static class TimedOutputStream.TimedOutputStreamInterrupt
           
 
Field Summary
private  boolean m_bTimedOut
           
private  java.io.OutputStream m_Out
           
private  long m_TimeoutInTicks
           
private  long m_TimeOutTick
           
private static long ms_currentTick
           
private static java.util.Hashtable ms_hashtableOutputStreams
           
(package private) static long MS_PER_TICK
           
private static java.lang.Thread ms_threadInterrupt
           
 
Constructor Summary
private TimedOutputStream()
           
  TimedOutputStream(java.io.OutputStream parent, long msTimeout)
           
 
Method Summary
 void close()
           
 void flush()
           
static void init()
           
 void write(byte[] b)
           
 void write(byte[] b, int i1, int i2)
           
 void write(int b)
          Writes the specified byte to this output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Out

private java.io.OutputStream m_Out

m_TimeoutInTicks

private long m_TimeoutInTicks

m_TimeOutTick

private volatile long m_TimeOutTick

m_bTimedOut

private volatile boolean m_bTimedOut

ms_threadInterrupt

private static java.lang.Thread ms_threadInterrupt

ms_hashtableOutputStreams

private static java.util.Hashtable ms_hashtableOutputStreams

ms_currentTick

private static volatile long ms_currentTick

MS_PER_TICK

static final long MS_PER_TICK
See Also:
Constant Field Values
Constructor Detail

TimedOutputStream

private TimedOutputStream()

TimedOutputStream

public TimedOutputStream(java.io.OutputStream parent,
                         long msTimeout)
Parameters:
parent - OutputStream the outputstrem which will be used for I/O operations
msTimeout - long the timeout in milli seconds for the write operations (zero means blocking I/O)
Method Detail

init

public static void init()

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this output stream.

Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte.
Throws:
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int i1,
                  int i2)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException