Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.PrintWriter;

public class Main {
    /**
     * Generates the XML open tag <fieldName>
     *
     * @param fieldName
     * @param isNull if true then generates a self closing tag
     * @param pw PrintWriter to write to
     * @throws ProcessException
     */
    static public void writeXMLStart(String fieldName, boolean isNull, PrintWriter pw) {
        writeXMLStart(fieldName, isNull, pw, false);
    }

    /**
     * Generates the XML open tag as follows:
     * <ul>
     * <li>If the isNull - &lt;fieldName/&gt;
     * <li>otherwise - &lt;fieldName&gt; a new line is inserted after this tag
     * if endWithNewLine = true
     * </ul>
     *
     * @param fieldName
     * @param isNull if true generates a self closing tag
     * @param pw
     * @param endWithNewLine if true then will add a new line after '>' tag
     * @throws Exception
     */
    static public void writeXMLStart(String fieldName, boolean isNull, PrintWriter pw, boolean endWithNewLine) {
        pw.print('<');
        pw.print(fieldName);
        if (isNull) {
            pw.println("/>");
        } else {
            if (endWithNewLine)
                pw.println('>');
            else
                pw.print('>');
        }
    }
}