Here you can find the source of writeFile(String directoryPath, String filename, byte[] bytes)
Parameter | Description |
---|---|
directoryPath | the directory to be used. |
filename | the file name to be written. |
bytes | the byte array. |
public static void writeFile(String directoryPath, String filename, byte[] bytes)
//package com.java2s; /**//from ww w. j a v a 2 s. c o m * Copyright 2005 British Broadcasting Corporation * * This file is part of the BBC R&D ID3v2 Chapter Tool application. * * The BBC R&D ID3v2 Chapter Tool application is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * The BBC R&D ID3v2 Chapter Tool application is distributed in the hope that it will * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General * Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with * the BBC R&D ID3v2 Chapter Tool application; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; public class Main { /** * Write a file containing the data in an array of bytes. * * @param directoryPath the directory to be used. * @param filename the file name to be written. * @param bytes the byte array. */ public static void writeFile(String directoryPath, String filename, byte[] bytes) { try { FileOutputStream os = new FileOutputStream(new File(directoryPath, filename)); BufferedOutputStream bos = new BufferedOutputStream(os); bos.write(bytes, 0, bytes.length); bos.flush(); os.flush(); bos.close(); os.close(); } catch (Exception e) { e.printStackTrace(); } } }