Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    /**
     * <pre>
     * 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();
    }
}