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.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.content.Context;

public class Main {
    public static void imgCacheWrite(Context context, String cacheImgFileName, String imgBase64Str) {
        File cacheImgFile = new File(context.getFilesDir() + "/" + cacheImgFileName);
        if (cacheImgFile.exists()) {
            cacheImgFile.delete();
        }

        FileOutputStream fos;
        try {
            fos = context.openFileOutput(cacheImgFileName, Context.MODE_PRIVATE);
            fos.write(imgBase64Str.getBytes("utf-8"));
            fos.flush();
            fos.close();

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}