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.InputStream;

import android.content.Context;

import android.util.Log;

public class Main {
    public static boolean saveRes(Context gContext, int res, String dirjpg) {
        InputStream is = gContext.getApplicationContext().getResources().openRawResource(res);
        boolean rez = false;
        try {
            FileOutputStream rtFOS = new FileOutputStream(dirjpg + "/" + res + ".gif");
            byte[] buffer = new byte[4096];
            int n = -1;
            while ((n = is.read(buffer, 0, 4095)) != -1) {
                if (n > 0)
                    rtFOS.write(buffer, 0, n);
                rez = true;
            }
            rtFOS.flush();
            rtFOS.close();
        } catch (Exception e) {
            Log.e("FullscreenActivity", e.toString());
        }
        return rez;
    }
}