001    package railo.commons.io.res.type.compress;
002    
003    import java.io.IOException;
004    import java.io.OutputStream;
005    
006    public final class CompressOutputStreamSynchronizer extends OutputStream {
007    
008            private final OutputStream os;
009            private final Compress zip;
010            private final boolean async;
011    
012            public CompressOutputStreamSynchronizer(OutputStream os, Compress zip,boolean async) {
013                    this.os=os;
014                    this.zip=zip;
015                    this.async=async;
016            }
017    
018            /**
019             *
020             * @see java.io.OutputStream#close()
021             */
022            public void close() throws IOException {
023                    os.close();
024                    zip.synchronize(async);
025            }
026    
027            /**
028             *
029             * @see java.io.OutputStream#flush()
030             */
031            public void flush() throws IOException {
032                    os.flush();
033            }
034    
035            /**
036             * @see java.io.OutputStream#write(int)
037             */
038            public void write(int b) throws IOException {
039                    os.write(b);
040            }
041    
042            /**
043             *
044             * @see java.io.OutputStream#write(byte[], int, int)
045             */
046            public void write(byte[] b, int off, int len) throws IOException {
047                    os.write(b, off, len);
048            }
049    
050            /**
051             *
052             * @see java.io.OutputStream#write(byte[])
053             */
054            public void write(byte[] b) throws IOException {
055                    os.write(b);
056            }
057    
058    }