001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.commons.io.res.type.compress; 020 021import java.io.IOException; 022import java.io.OutputStream; 023 024public final class CompressOutputStreamSynchronizer extends OutputStream { 025 026 private final OutputStream os; 027 private final Compress zip; 028 private final boolean async; 029 030 public CompressOutputStreamSynchronizer(OutputStream os, Compress zip,boolean async) { 031 this.os=os; 032 this.zip=zip; 033 this.async=async; 034 } 035 036 @Override 037 public void close() throws IOException { 038 os.close(); 039 zip.synchronize(async); 040 } 041 042 @Override 043 public void flush() throws IOException { 044 os.flush(); 045 } 046 047 @Override 048 public void write(int b) throws IOException { 049 os.write(b); 050 } 051 052 @Override 053 public void write(byte[] b, int off, int len) throws IOException { 054 os.write(b, off, len); 055 } 056 057 @Override 058 public void write(byte[] b) throws IOException { 059 os.write(b); 060 } 061 062}