Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import android.content.Context;

public class Main {
    private static void copyResourceFile(Context context, int rid, String targetFile) throws IOException {
        InputStream fin = context.getResources().openRawResource(rid);
        FileOutputStream fos = new FileOutputStream(targetFile);

        int length;
        byte[] buffer = new byte[1024 * 32];
        while ((length = fin.read(buffer)) != -1) {
            fos.write(buffer, 0, length);
        }
        fin.close();
        fos.close();
    }
}