Home » Core Java » util » Properties » Convert XML File into Properties object

About Nikos Maravitsas

Nikos Maravitsas
Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens. During his studies he discovered his interests about software development and he has successfully completed numerous assignments in a variety of fields. Currently, his main interests are system’s security, parallel systems, artificial intelligence, operating systems, system programming, telecommunications, web applications, human – machine interaction and mobile development.

Convert XML File into Properties object

In the previous tutorial we saw how to convert Properties object to XML Format and write it to XML File. In this tutorial we are going to show you how to the opposite, that is convert an XML File into a Properties object in Java.
Here is the XML File that we’ve created in the previous tutorial :


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<entry key="email">example@javacodegeeks.com</entry>


package com.javacodegeeks.java.core;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class XMLFileToPropertiesExample {

	private static final String xmlFilePath = "C:\\Users\\nikos7\\Desktop\\filesForExamples\\emailProps.xml";

	public static void main(String[] args) throws IOException {

		Properties properties = new Properties();

		FileInputStream fileStream = new FileInputStream(xmlFilePath);


    	String email = properties.getProperty("email");





This was an example on how to

(No Ratings Yet)
Start the discussion Views Tweet it!

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area


Leave a Reply

Notify of