Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import android.content.Context;

public class Main {
    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);
        is.close();

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