Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

Java Properties File Example

In this tutorial you will learn that how to use java properties file in java for localisation


How to read properties file in Java? Generate random numbers in Java Cloneable Interface in Java What is the flaw with the Stack class? List In Java Java Stack Example HashSet In Java Enumeration in java How to generate random number in java Iterator in java Queue in java Transient Java Keyword clone method in Java Java Queue example Logger in Java Java current date - How to get current date in Java Collection : LinkedList Example Collection : ArrayList Example Random alpha numeric string of fixed size Java List Iterator Example The Hashtable Class The BitSet class Java Vector Java Enumeration Data Structures in Java Java Transient Variable Java Date Format Example Java Properties File Example Map.Entry Java Interface Java Property File java preferences,Change the value of Preferences by user Retrieving a Preference Node Java hasNext Write Keys and Values to the Properties file in Java Get All Keys and Values of the Properties files in Java Properties file in Java Properties file in Java Determining If a Preference Node Contains a Specific Value Change the value of Preferences by user Clone method example in Java Implementing a Simple Event Notifier Determining When a Preference Node Is Added or Removed Listening for Changes to Preference Values in a Preference Node Importing Preferences Finding a Preference in a Preference Tree Retrieving the Parent and Child Nodes of a Preference Node Determining If a Preference Node Exists Removing a Preference Node Creating a Preference Node Getting the Maximum Size of a Preference Key and Value


Using Properties files Java


Stets to use a properties files in Java.

1. At first create a properties files and save it in a UTF-8 format.

2. Then Make an object of Properties class.

3. After that load the properties file into the program.

4. Finally get the text using the key of the properties file.

An example of using the properties file and changing the caption French language is given below. To run the given example please save the properties file into the c directory of your computer.

Here is the video tutorial of: "How to read properties file in Swing Application?"

Using Properties files Java Code

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Properties;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class MyWindows extends JFrame {
	public MyWindows() {

	public static void main(String args[]) {
		MyWindows myWindows = new MyWindows();
		final Properties myresources = new Properties();

		try {
			FileInputStream in = new FileInputStream(
			try {
				System.out.println("Properties File Loaded");
			} catch (Exception e) {
		} catch (Exception e) {

		final JFrame myFrame = new JFrame("My Windows");
		myFrame.setSize(600, 400);
		myFrame.setLayout(new FlowLayout());
		final JButton testButton = new JButton("Change Laguage");
		final JLabel testLabel = new JLabel("Hello Friends");

		testButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub


When you run this application it will display message as shown below:


Download Select Source Code


Share on Google+Share on Google+

Java Properties File Example

Posted on: July 23, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Java Properties File Example  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image