Java Utility Library

Java Properties - list() Method



The java.util.Properties.list() method is used to print this property list out to the specified output stream. This method is useful for debugging.

Syntax

public void list(PrintStream out)

Parameters

out Specify an output stream.

Return Value

void type.

Exception

Throws ClassCastException, if any key in this property list is not a string.

Example:

In the example below, the java.util.Properties.list() method is used to print the given property list out to the specified output stream.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a Properties
    Properties Prop = new Properties();

    //adding some values
    Prop.put("Blue", "10");
    Prop.put("Red", "20");
    Prop.put("Green", "30");

    //printing the list with System.out
    Prop.list(System.out);

  }
}

The output of the above code will be:

-- listing properties --
Red=20
Blue=10
Green=30

❮ Java.util - Properties