Example usage for java.io FileOutputStream close

List of usage examples for java.io FileOutputStream close

Introduction

In this page you can find the example usage for java.io FileOutputStream close.

Prototype

public void close() throws IOException 

Source Link

Document

Closes this file output stream and releases any system resources associated with this stream.

Usage

From source file:Main.java

public static void decoderBase64File(String base64Code, String savePath) throws Exception {
    byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT);
    FileOutputStream out = new FileOutputStream(savePath);
    out.write(buffer);//from w  w  w  . jav a  2 s. com
    out.close();
}

From source file:Main.java

public static void decoderBase64File(String base64Code, String savePath) throws Exception {
    //byte[] buffer = new BASE64Decoder().decodeBuffer(base64Code);
    byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT);
    FileOutputStream out = new FileOutputStream(savePath);
    out.write(buffer);//from w w  w.  j  a v a  2  s  . c o  m
    out.close();
}

From source file:Main.java

static void write(byte[] data, String fname) throws Exception {
    FileOutputStream out = new FileOutputStream(fname);
    out.write(data);//w ww .ja  va 2  s  .  c  o m
    out.close();
}

From source file:Main.java

private static void writeToFile(File file, String uuid) throws IOException {
    file.createNewFile();//from ww w .j a v  a 2 s. c  o m
    FileOutputStream out = new FileOutputStream(file);
    out.write(uuid.getBytes());
    out.close();
}

From source file:Main.java

public static void writeFile(File file, byte[] b) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(b);/*from w ww .  j av  a 2  s.c  om*/
    fos.close();
}

From source file:Main.java

public static void copyAssetFileToFiles(Context context, String root, String filename) throws IOException {
    InputStream is = context.getAssets().open(filename);
    byte[] buffer = new byte[is.available()];
    is.read(buffer);//from  w w  w .j a va2  s . co m
    is.close();

    File tgtfile = new File(root + "/" + filename);
    tgtfile.createNewFile();
    tgtfile.setExecutable(true);
    FileOutputStream os = new FileOutputStream(tgtfile);
    os.write(buffer);
    os.close();
}

From source file:Main.java

public static boolean writeBytes(String filePath, byte[] data) {
    try {/*from w w w.j a  va 2s. c o m*/
        FileOutputStream fos = new FileOutputStream(filePath);
        fos.write(data);
        fos.close();
        return true;
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
    return false;
}

From source file:Main.java

/**
 * <pre>//  w w w.  ja  v  a 2  s .  co  m
 * Save byte array to arbitrary file.
 * </pre>
 * @param in byte array
 * @param absolutePath absolute path to destination file
 */
public static void saveFile(byte[] in, String absolutePath) throws IOException {
    File file = new File(absolutePath);
    if (!file.exists()) {
        file.createNewFile();
    }

    FileOutputStream out = new FileOutputStream(absolutePath);
    out.write(in);
    out.close();
}

From source file:Main.java

public static void saveImage(File file, byte[] bytes) throws Exception {
    file.delete();/*from w w w  .  j a  v  a2  s . co m*/
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(bytes);
    fos.flush();
    fos.close();
}

From source file:Main.java

public static void writeFile(File file, String content) throws Exception {
    FileOutputStream outStream = new FileOutputStream(file);
    outStream.write(content.getBytes());
    outStream.close();
}