How to read a Java Properties file

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

Here is 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

Also, if it helps to know it, a 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

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.