Here you can find the source of saveToFile(File file, byte[] buffer)
Parameter | Description |
---|---|
file | the Java file object where the bytes will be stored. |
buffer | the array of bytes. |
public static void saveToFile(File file, byte[] buffer) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2013-2015 UAH Space Research Group. * 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:// w ww.j a va 2 s. c o m * MICOBS SRG Team - Initial API and implementation ******************************************************************************/ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** * Saves an array of bytes to a file in the file system. * * If an error occurs when storing the data, the method * will throw an {@link IOException}. * * @param file the Java file object where the bytes will be * stored. * @param buffer the array of bytes. */ public static void saveToFile(File file, byte[] buffer) throws IOException { FileOutputStream out = new FileOutputStream(file); try { out.write(buffer); } finally { out.close(); } } }