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.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    /**
     * Write a string to a file
     *  @param content The string to write out
     *  @param outputfile The file to which the string will be written
     */
    public static void writeStringToFile(String content, File outputfile) {
        if (content != null && !content.equals("") && outputfile != null) {
            try {
                PrintWriter pwriter = new PrintWriter(new FileWriter(outputfile));
                pwriter.print(content);
                pwriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}