Java.util.Properties.list() Method



Description

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

Declaration

Following is the declaration for java.util.Properties.list() method

public void list(PrintStream out)

Parameters

out − an output stream.

Return Value

This method does not return a value.

Exception

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

Example

The following example shows the usage of java.util.Properties.list() method.

package com.tutorialspoint;

import java.util.*;

public class PropertiesDemo {
   public static void main(String[] args) {
      Properties prop = new Properties();

      // add some properties
      prop.put("Height", "200");
      prop.put("Width", "150");
      prop.put("Scannable", "true");

      // print the list with System.out
      prop.list(System.out);
   }
}

Let us compile and run the above program, this will produce the following result −

-- listing properties --
Width = 150
Height = 200
Scannable = true
java_util_properties.htm
Advertisements