TrueZIP Kernel 7.0-rc1

de.schlichtherle.truezip.io
Class SynchronizedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by de.schlichtherle.truezip.io.DecoratingOutputStream
          extended by de.schlichtherle.truezip.io.SynchronizedOutputStream
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
ConcurrentOutputShop.SynchronizedConcurrentOutputStream

public class SynchronizedOutputStream
extends DecoratingOutputStream

A decorator which synchronizes all access to an OutputStream via an object provided to its constructor.

Author:
Christian Schlichtherle
See Also:
SynchronizedInputStream

Field Summary
protected  Object lock
          The object to synchronize on - never null.
 
Fields inherited from class de.schlichtherle.truezip.io.DecoratingOutputStream
delegate
 
Constructor Summary
SynchronizedOutputStream(OutputStream out)
          Constructs a new synchronized output stream.
SynchronizedOutputStream(OutputStream out, Object lock)
          Constructs a new synchronized output stream.
 
Method Summary
 void close()
           
 void flush()
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class de.schlichtherle.truezip.io.DecoratingOutputStream
toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lock

protected final Object lock
The object to synchronize on - never null.

Constructor Detail

SynchronizedOutputStream

public SynchronizedOutputStream(OutputStream out)
Constructs a new synchronized output stream. This object will synchronize on itself.

Parameters:
out - the output stream to wrap in this decorator.

SynchronizedOutputStream

public SynchronizedOutputStream(OutputStream out,
                                Object lock)
Constructs a new synchronized output stream.

Parameters:
out - the output stream to wrap in this decorator.
lock - the object to synchronize on. If null, then this object is used, not the stream.
Method Detail

write

public void write(int b)
           throws IOException
Overrides:
write in class DecoratingOutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class DecoratingOutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class DecoratingOutputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class DecoratingOutputStream
Throws:
IOException

TrueZIP Kernel 7.0-rc1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.