Here you can find the source of writeBytesToStream(byte[] bytes, OutputStream outputStream)
public static void writeBytesToStream(byte[] bytes, OutputStream outputStream) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2014 Bruno Medeiros and other Contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w. j a va 2 s. co m * Bruno Medeiros - initial implementation *******************************************************************************/ import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; public class Main { /** Writes given bytes array to given outputStream. * Closes outputStream afterwards. */ public static void writeBytesToStream(byte[] bytes, OutputStream outputStream) throws IOException { // A BufferedOutputStream is likely not necessary since this is a one-time array write BufferedOutputStream bos = new BufferedOutputStream(outputStream); try { bos.write(bytes); } finally { bos.close(); } } }