Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import android.util.Log;

public class Main {
    /**
     * (java)write to file
     * 
     * @param str
     * @param path
     */
    public static void writeFile(String str, File file) {
        FileOutputStream out;
        try {
            file.createNewFile();

            out = new FileOutputStream(file, false);
            String infoToWrite = str;
            out.write(infoToWrite.getBytes());
            out.close();

        } catch (IOException e) {
            Log.e("", "write error!");
        }
    }
}