- Java.util Package Classes
- Java.util - Home
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util Package Extras
- Java.util - Interfaces
- Java.util - Exceptions
- Java.util - Enumerations
- Java.util Useful Resources
- Java.util - Useful Resources
- Java.util - Discussion
Java Properties list() Method
Description
The Java 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.
Java Properties list(PrintWriter out) Method
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.
Listing Key-Value pairs of Properties to Console Example
The following example shows the usage of Java Properties list(PrintStream) method to print the properties to a stream. We're using System.out as PrintStream.
package com.tutorialspoint; import java.util.Properties; 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); } }
Output
Let us compile and run the above program, this will produce the following result −
-- listing properties -- Width = 150 Height = 200 Scannable = true
Listing Key-Value pairs of Properties to Console Using PrintWrite Example
The following example shows the usage of Java Properties list(PrintWriter) method to print the properties to a writer object. We're using System.out as PrintWriter.
package com.tutorialspoint; import java.io.PrintWriter; import java.util.Properties; 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(); } }
Output
Let us compile and run the above program, this will produce the following result −
-- listing properties -- Width = 150 Height = 200 Scannable = true
To Continue Learning Please Login
Login with Google