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

import android.content.*;

import android.util.Log;

public class Main {
    public static void logScanReport(Context c, String[] logs) {
        String dir = c.getExternalFilesDir(null).getParent();
        try {
            File file = new File(dir + "/last_scan.log");
            boolean append = false;
            // if file doesnt exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            } else {
                /*
                if(file.length() >= 2097152){
                   // set log file max size to 2mb
                   append = false;
                }
                 */
            }
            FileOutputStream fos = new FileOutputStream(file, append);

            for (String log : logs) {
                fos.write((log + "\n\n").getBytes());
            }
            fos.close();
        } catch (IOException ioe) {
            Log.e("AndroidUtils", "An exception has occured in logScanReport!");
            ioe.printStackTrace();
        }
    }
}