Java.util.Properties.list() Method


Advertisements


Description

The java.util.Properties.list(PrintWriter 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(PrintWriter 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.io.PrintWriter;
import java.util.*;

public class PropertiesDemo {

   public static void main(String[] args) {
   Properties prop = new Properties();
   PrintWriter writer = new PrintWriter(System.out);

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

   // print the list with a PrintWriter object
   prop.list(writer);

   // flush the stream
   writer.flush();

   }
}

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