diff --git a/src/java.base/share/classes/java/util/Properties.java b/src/java.base/share/classes/java/util/Properties.java index 015cdbc7107e0..824e92791dd7a 100644 --- a/src/java.base/share/classes/java/util/Properties.java +++ b/src/java.base/share/classes/java/util/Properties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1211,10 +1211,22 @@ public Set stringPropertyNames() { } /** - * Prints this property list out to the specified output stream. + * Prints this property list out to the specified {@link PrintStream}. * This method is useful for debugging. * - * @param out an output stream. + * @implNote The implementation of this method truncates the output for very long + * property values. + *

+ * An alternative for listing the {@code Properties} to a {@code PrintStream} + * without truncation is: + * {@snippet lang=java : + * Properties p = ... + * PrintStream out = ... + * // list the properties to PrintStream + * p.forEach((k, v) -> out.println(k + "=" + v)); + * } + * + * @param out the output PrintStream * @throws ClassCastException if any key in this property list * is not a string. */ @@ -1233,10 +1245,22 @@ public void list(PrintStream out) { } /** - * Prints this property list out to the specified output stream. + * Prints this property list out to the specified {@link PrintWriter}. * This method is useful for debugging. * - * @param out an output stream. + * @implNote The implementation of this method truncates the output for very long + * property values. + *

+ * An alternative for listing the {@code Properties} to a {@code PrintWriter} + * without truncation is: + * {@snippet lang=java : + * Properties p = ... + * PrintWriter out = ... + * // list the properties to PrintWriter + * p.forEach((k, v) -> out.println(k + "=" + v)); + * } + * + * @param out the output PrintWriter * @throws ClassCastException if any key in this property list * is not a string. * @since 1.1