java.io Code Samples
- How can I get current working directory?
- How do I detect non-ASCII characters in string?
- How can I change a file attribute to writable?
- How do I create a directories recursively?
- How do I use Java NIO to Copy File?
- How do I copy a file?
- How do I check if a directory is not empty?
- How do I rename a file or directory?
- How do I get total space and free space of my disk?
- How do I create a new directory?
- How do I get the absolute path of a file?
- How do I get the content of a directory?
- How can I change a file attribute to read only?
- How do I check if a file exists?
How do I load properties from XML file?
Reading XML properties can be easily done using the Properties.loadFromXML() method. Just like reading the properties from a file that contains a key=value pairs, the XML file will also contains a key and value wrapped in the following XML format.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Application Configuration</comment> <entry key="data.folder">D:\App\Data</entry> <entry key="jdbc.url">jdbc:mysql://localhost/mydb</entry> </properties>