Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/* LemonTree 
 * 
 * Copyright (c) 2012 Tom Michoel, Eric Bonnet 
 * 
 * LemonTree is free software, released under the terms of the GNU general
 * Public License (GPL) v2. See LICENSE file for details.  
 *
 */

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Main {
    public static void saveToFile(String fileName, String str) throws IOException {
        File f = new File(fileName);
        if (!f.exists()) {
            if (f.getParent() != null) {
                new File(f.getParent()).mkdirs();
            }
            f.createNewFile();
        }
        FileWriter fw = new FileWriter(f);
        fw.write(str);
        fw.close();
    }
}