Storing Values to XML file using JAVA

Create a xml file named Test.xml in source folder.
And using the pasted code we can write in to any xml file..

Many options are available for generating XML documents. XmlWriter is by no means the best tool for every XML creation task, but it can fill the gap that exists between approaches that are too simple, too heavy, and too complex.

Here we used XMLEncoder class.
using the BufferedOutputStream we can write to the xml file:)

Here we have a small example which can easily understandable::::

 * @(#)
 * DemoApp application
 * @Sujay
 * @version 1.00 2011/7/25

 import java.beans.XMLEncoder;

public class DemoApp extends javax.swing.JFrame{
    public static void main(String[] args)throws FileNotFoundException
    try {
    // TODO, add your application code
    XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("Test.xml")));
        e.writeObject("Hello, world");
        } catch(FileNotFoundException ex) {
                System.out.print("Error  :"+ex);

Popular posts from this blog

Android Jetpack Overview

Understand Instant App in Android

Step by step installation of Android 8.0 Oreo for Pixel and Nexus