Created
November 24, 2015 18:15
-
-
Save Crydust/d77956cbfa24f6e7b567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz; | |
import java.io.Writer; | |
import java.nio.charset.StandardCharsets; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import javax.xml.stream.XMLOutputFactory; | |
import javax.xml.stream.XMLStreamWriter; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
String fileName = "dummy.xml"; | |
try (Writer out = Files.newBufferedWriter(Paths.get(fileName), StandardCharsets.UTF_8)) { | |
XMLOutputFactory xof = XMLOutputFactory.newInstance(); | |
XMLStreamWriter xtw = xof.createXMLStreamWriter(out); | |
xtw.writeStartDocument("UTF-8", "1.0"); | |
xtw.writeDTD("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"); | |
xtw.writeStartElement("plist"); | |
xtw.writeAttribute("version", "1.0"); | |
xtw.writeStartElement("dict"); | |
xtw.writeCharacters("\n"); | |
xtw.writeStartElement("key"); | |
xtw.writeCharacters("Label"); | |
xtw.writeEndElement(); | |
xtw.writeStartElement("string"); | |
xtw.writeCharacters("xyz"); | |
xtw.writeEndElement(); | |
xtw.writeCharacters("\n"); | |
// dict | |
xtw.writeEndElement(); | |
// plist | |
xtw.writeEndElement(); | |
xtw.writeEndDocument(); | |
xtw.flush(); | |
xtw.close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment