Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.BufferedWriter;

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

public class Main {
    public static boolean saveStringToFile(String fileName, String saveString) {

        boolean saved = false;
        BufferedWriter bw = null;

        try {
            bw = new BufferedWriter(new FileWriter(fileName));

            try {
                bw.write(saveString);
                saved = true;
            } finally {
                bw.close();
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        return saved;
    }
}