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

import java.io.FileOutputStream;

public class Main {
    public static void intArrayToFile(Context myContext, String filename, int[] array) {
        File root = myContext.getFilesDir();
        File current = new File(root, filename);
        current.delete();
        FileOutputStream outputStream;
        try {
            outputStream = myContext.openFileOutput(filename, Context.MODE_APPEND);
            for (int i : array) {
                String s = "" + i;
                outputStream.write(s.getBytes());
                outputStream.write("\n".getBytes());
            }
            outputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}