001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.io.unsync;
016    
017    import java.io.IOException;
018    import java.io.OutputStream;
019    
020    /**
021     * <p>
022     * See http://issues.liferay.com/browse/LPS-6648.
023     * </p>
024     *
025     * @author Shuyang Zhou
026     */
027    public class UnsyncFilterOutputStream extends OutputStream {
028    
029            public UnsyncFilterOutputStream(OutputStream outputStream) {
030                    this.outputStream = outputStream;
031            }
032    
033            @Override
034            public void close() throws IOException {
035                    try {
036                            flush();
037                    }
038                    catch (IOException ioe) {
039                    }
040    
041                    outputStream.close();
042            }
043    
044            @Override
045            public void flush() throws IOException {
046                    outputStream.flush();
047            }
048    
049            @Override
050            public void write(byte[] bytes) throws IOException {
051                    outputStream.write(bytes, 0, bytes.length);
052            }
053    
054            @Override
055            public void write(byte[] bytes, int offset, int length)
056                    throws IOException {
057    
058                    outputStream.write(bytes, offset, length);
059            }
060    
061            @Override
062            public void write(int b) throws IOException {
063                    outputStream.write(b);
064            }
065    
066            protected OutputStream outputStream;
067    
068    }