public class XmlWriter extends Writer
StringWriter writer = new StringWriter(); XmlWriter xml = new XmlWriter(writer); xml.element("meow") .attribute("moo", "cow") .element("child") .attribute("moo", "cow") .element("child") .attribute("moo", "cow") .text("XML is like violence. If it doesn't solve your problem, you're not using enough of it.") .pop() .pop() .pop(); System.out.println(writer);
Modifier and Type | Field and Description |
---|---|
int |
indent |
Modifier and Type | Method and Description |
---|---|
XmlWriter |
attribute(String name,
Object value) |
void |
close()
Calls
pop() for each remaining open element, if any, and closes the stream. |
XmlWriter |
element(String name) |
XmlWriter |
element(String name,
Object text) |
void |
flush() |
XmlWriter |
pop() |
XmlWriter |
text(Object text) |
void |
write(char[] cbuf,
int off,
int len) |
public XmlWriter(Writer writer)
public XmlWriter element(String name) throws IOException
IOException
public XmlWriter element(String name, Object text) throws IOException
IOException
public XmlWriter attribute(String name, Object value) throws IOException
IOException
public XmlWriter text(Object text) throws IOException
IOException
public XmlWriter pop() throws IOException
IOException
public void close() throws IOException
pop()
for each remaining open element, if any, and closes the stream.close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
public void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
Copyright © 2019. All rights reserved.