How to read a Java Properties file

Java Properties file FAQ: Can you show me how to read a Java Properties file?


Sure. Here’s a snippet of Java source code that shows how to read a Java Properties file named It reads in two properties named CRUST and TOPPINGS.:

Properties properties = new Properties();
FileInputStream in = new FileInputStream("");

String crust = properties.getProperty("CRUST");
String toppings = properties.getProperty("TOPPINGS");

This simple coding approach makes using Java Properties files very convenient to use for storing your application properties.

What a properties file looks like

A Java Properties file has a collection of name/value pairs, separated by an equal sign, and comments allowed, like this:

# the user's name

# the user's zip code