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 java.io.OutputStream;
import android.content.Context;

public class Main {
    public static void assetsDataToSD(String fileOutPutName, String fileInPutName, Context context)
            throws IOException {
        InputStream myInput;
        File file = new File(fileOutPutName);
        /*if (!file.exists()) {
        file.createNewFile();
           }else {
           return;
        }*/
        OutputStream myOutput = new FileOutputStream(fileOutPutName);
        myInput = context.getAssets().open(fileInPutName);
        byte[] buffer = new byte[1024];
        int length = myInput.read(buffer);
        while (length > 0) {
            myOutput.write(buffer, 0, length);
            length = myInput.read(buffer);
        }

        myOutput.flush();
        myInput.close();
        myOutput.close();
    }
}