Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {

    public static boolean writeFile(String to, String value) {
        boolean result = false;

        FileOutputStream out = null;

        try {
            out = new FileOutputStream(to);
            byte[] buffer = value.getBytes();
            out.write(buffer, 0, value.length());
            out.flush();
            result = true;
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
            }
        }
        return result;

    }
}