FileDocCategorySizeDatePackage
TestXMLProperties.javaAPI DocExample3661Sat Sep 01 15:39:28 BST 2001javaxml2

TestXMLProperties

public class TestXMLProperties extends Object
TestXMLProperties is a simple class that tests usage of the {@link XMLProperties} class for reading XML property files.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

Provide a static entry point for testing.

        if (args.length != 2) {
            System.out.println("Usage: java javaxml2.TestXMLProperties " +
                "[XML input document] [XML output document]");
            System.exit(0);
        }
    
        try {
            // Create and load properties
            System.out.println("Reading XML properties from " + args[0]);
            XMLProperties props = new XMLProperties();
            props.load(new FileInputStream(args[0]));
            
            // Print out properties and values
            System.out.println("\n\n---- Property Values ----");
            Enumeration names = props.propertyNames();
            while (names.hasMoreElements()) {
                String name = (String)names.nextElement();
                String value = props.getProperty(name);
                System.out.println("Property Name: " + name + 
                                   " has value " + value);
            }            
            
            // Store properties
            System.out.println("\n\nWriting XML properies to " + args[1]);
            props.store(new FileOutputStream(args[1]),
                "Testing XMLProperties class");
        } catch (Exception e) {
            e.printStackTrace();
        }