Java OutputStream Write writeStream(byte[] data, OutputStream out)

Here you can find the source of writeStream(byte[] data, OutputStream out)

Description

Writes data into the stream and closes the output stream

License

Open Source License

Exception

Parameter Description
IOException if an I/O error occurs.

Declaration

public static void writeStream(byte[] data, OutputStream out) throws IOException 

Method Source Code

//package com.java2s;
/*//from  w  w w .java 2s  . c o  m
* Copyright (c) 2000 - 2005 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  
*
*/

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    /**
     * Writes data into the stream and closes the output stream
     *
     * @throws IOException if an I/O error occurs.
     */
    public static void writeStream(byte[] data, OutputStream out) throws IOException {
        try {
            out.write(data);
            out.flush();
        } finally {
            out.close();
        }
    }
}

Related

  1. serializeString(String str, DataOutputStream dout)
  2. serializeTo(OutputStream outputStream, Object obj)
  3. serializeToOutputStream(final Serializable ser, final OutputStream os)
  4. serializeUUID(OutputStream out, UUID id)
  5. writeStream(byte[] data, OutputStream os)
  6. writeStream(final OutputStream out, final String content, final boolean close)
  7. writeStream(InputStream _from, Writer _printTo)
  8. writeStream(InputStream in, File file)
  9. writeStream(InputStream inputStream, OutputStream out)