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.File;

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

public class Main {
    public static BufferedWriter getWriter(File file, final String group, String comment) throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter(file)) {

            @Override
            public void close() throws IOException {
                write("</" + group + ">");
                super.close();
            }
        };
        bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        bw.newLine();
        bw.newLine();
        bw.write("<!--" + comment + "-->");
        bw.newLine();
        bw.newLine();
        bw.write("<" + group + ">");
        bw.newLine();

        return bw;
    }
}