Here you can find the source of writeFile(String destination, byte[] data, boolean append)
Parameter | Description |
---|---|
destination | a parameter |
data | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeFile(String destination, byte[] data, boolean append) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /**//from w ww .j a v a2 s .c om * writeFile * * @param destination * @param data * @throws IOException */ public static void writeFile(String destination, byte[] data, boolean append) throws IOException { File temp = new File(destination); if (temp.exists() && append == true) { FileOutputStream fos = new FileOutputStream(temp, true); try { fos.write(data); fos.flush(); } finally { fos.close(); } } else { FileOutputStream fos = new FileOutputStream(temp); try { fos.write(data); fos.flush(); } finally { fos.close(); } } } /** * existFile * * @param path * @return */ public static boolean exists(String path) { try { File temp = new File(path); return temp.exists(); } catch (Exception e) { // ignore } return false; } }