GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.tutorialspoint.com — Java Properties loadFromXML() Method
Selected Reading
Java Properties loadFromXML() MethodDescriptionThe java Properties loadFromXML(InputStream in) method loads all of the properties represented by the XML document on the specified input stream into this properties table. DeclarationFollowing is the declaration for java.util.Properties.loadFromXML() method public void loadFromXML(InputStream in) Parametersin − the input stream from which to read the XML document. Return ValueThis method does not return a value. Exception
Loading Properties From an XML File ExampleThe following example shows the usage of Java Properties loadFromXML(Stream) method to load the properties from a xml file. package com.tutorialspoint;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class PropertiesDemo {
public static void main(String[] args) {
Properties prop = new Properties();
// add some properties
prop.put("Height", "200");
prop.put("Width", "15");
try {
// create a output and input as a xml file
FileOutputStream fos = new FileOutputStream("properties.xml");
FileInputStream fis = new FileInputStream("properties.xml");
// store the properties in the specific xml
prop.storeToXML(fos, null);
// load from the xml that we saved earlier
prop.loadFromXML(fis);
// print the properties list
prop.list(System.out);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
OutputLet us compile and run the above program, this will produce the following result − -- listing properties -- Height=200 Width=15 java_util_properties.htm
Advertisements
|
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |