Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;

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

public class Main {
    static public Activity _context;

    public static void writeBuffer2InternalStorage(String path, byte[] data) {
        File file = new File(_context.getFilesDir() + File.separator + path);

        try {
            FileOutputStream outstream;

            if (!file.exists()) {
                file.createNewFile();
            }

            outstream = new FileOutputStream(file);
            outstream.write(data);
            outstream.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}