Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.OutputStream;
import java.io.OutputStreamWriter;

import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;

public class Main {

    public static void main(String[] args) throws Exception {
        OutputStream stream = System.out;

        XMLOutputFactory xof = XMLOutputFactory.newFactory();
        XMLStreamWriter xsw = xof.createXMLStreamWriter(stream);

        xsw.writeStartDocument();
        xsw.writeStartElement("foo");
        xsw.writeStartElement("bar");

        xsw.writeCharacters("");
        xsw.flush();

        OutputStreamWriter osw = new OutputStreamWriter(stream);
        osw.write("<baz>Hello World<baz>");
        osw.flush();

        xsw.writeEndElement();
        xsw.writeEndElement();
        xsw.writeEndDocument();
        xsw.close();
    }

}