Creating an XML File

Before exploring XOM, you should learn some things about XML and how it stores data. XML data turns up in countless places—it can be stored to a file, transmitted over an Internet network, and held in a program’s memory.

Several classes in the Java class library can read and write XML, including the Properties class in the java.util package, which was covered in Hour 20, “Reading and Writing Files.”

A Properties object can be stored as XML rather than in the name=value format covered in the preceding hour.

After the object has been filled with configuration properties, its storeToXML() method saves it to an XML file. This method takes two arguments:

• A FileOutputStream over which the file should be saved

• A comment, which ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.