Properties void list(PrintWriter out) method Example Program


Prints this property list out to the specified output stream. This method is useful for debugging.

Program

package com.candidjava;
import java.io.PrintWriter;
import java.util.Properties;
/* 
 * @author : Mohan 
 * @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. 
 */
public class PropertiesPrintWriter {
	public static void main(String[] args) {
		Properties prop = new Properties();
		PrintWriter writer = new PrintWriter(System.out);

		// add some properties
		prop.put("Breadth", "600");
		prop.put("Length", "140");
		prop.put("Honesty", "true");

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

		// flush the stream
		writer.flush();

	}
}

Output

-- listing properties --
Honesty=true
Length=140
Breadth=600

Explanation

public void list(PrintWriter out)
Prints this property list out to the specified output stream. This method is useful for debugging.
Parameters:
out - an output stream.
Throws:
ClassCastException - if any key in this property list is not a string.
Since:
JDK1.1


Related Post

Comments


©candidjava.com