diff --git a/src/java.base/share/classes/java/io/BufferedReader.java b/src/java.base/share/classes/java/io/BufferedReader.java index 6953061628e..2cd027c8bd8 100644 --- a/src/java.base/share/classes/java/io/BufferedReader.java +++ b/src/java.base/share/classes/java/io/BufferedReader.java @@ -47,10 +47,9 @@ import jdk.internal.misc.InternalLock; * operations may be costly, such as FileReaders and InputStreamReaders. For * example, * - *
- * BufferedReader in
- *   = new BufferedReader(new FileReader("foo.in"));
- * 
+ * {@snippet lang=java : + * BufferedReader in = new BufferedReader(new FileReader("foo.in")); + * } * * will buffer the input from the specified file. Without buffering, each * invocation of read() or readLine() could cause bytes to be read from the diff --git a/src/java.base/share/classes/java/io/BufferedWriter.java b/src/java.base/share/classes/java/io/BufferedWriter.java index 4cb958afd74..4904f718072 100644 --- a/src/java.base/share/classes/java/io/BufferedWriter.java +++ b/src/java.base/share/classes/java/io/BufferedWriter.java @@ -48,10 +48,9 @@ import jdk.internal.misc.VM; * to wrap a BufferedWriter around any Writer whose write() operations may be * costly, such as FileWriters and OutputStreamWriters. For example, * - *
- * PrintWriter out
- *   = new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
- * 
+ * {@snippet lang=java : + * PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out"))); + * } * * will buffer the PrintWriter's output to the file. Without buffering, each * invocation of a print() method would cause characters to be converted into diff --git a/src/java.base/share/classes/java/io/ByteArrayOutputStream.java b/src/java.base/share/classes/java/io/ByteArrayOutputStream.java index 1052b057d17..109acce3853 100644 --- a/src/java.base/share/classes/java/io/ByteArrayOutputStream.java +++ b/src/java.base/share/classes/java/io/ByteArrayOutputStream.java @@ -228,19 +228,17 @@ public class ByteArrayOutputStream extends OutputStream { * *

An invocation of this method of the form * - *

 {@code
-     *      ByteArrayOutputStream b = ...
-     *      b.toString("UTF-8")
-     *      }
-     * 
+ * {@snippet lang=java : + * ByteArrayOutputStream b; + * b.toString("UTF-8") + * } * * behaves in exactly the same way as the expression * - *
 {@code
-     *      ByteArrayOutputStream b = ...
-     *      b.toString(StandardCharsets.UTF_8)
-     *      }
-     * 
+ * {@snippet lang=java : + * ByteArrayOutputStream b; + * b.toString(StandardCharsets.UTF_8) + * } * * * @param charsetName the name of a supported @@ -282,9 +280,9 @@ public class ByteArrayOutputStream extends OutputStream { * copied into it. Each character c in the resulting string is * constructed from the corresponding element b in the byte * array such that: - *
{@code
+     * {@snippet lang=java :
      *     c == (char)(((hibyte & 0xff) << 8) | (b & 0xff))
-     * }
+ * } * * @deprecated This method does not properly convert bytes into characters. * As of JDK 1.1, the preferred way to do this is via the diff --git a/src/java.base/share/classes/java/io/CharArrayWriter.java b/src/java.base/share/classes/java/io/CharArrayWriter.java index 0045c242cdf..f084d6245a8 100644 --- a/src/java.base/share/classes/java/io/CharArrayWriter.java +++ b/src/java.base/share/classes/java/io/CharArrayWriter.java @@ -152,8 +152,9 @@ public class CharArrayWriter extends Writer { *

An invocation of this method of the form {@code out.append(csq)} * behaves in exactly the same way as the invocation * - *

-     *     out.write(csq.toString()) 
+ * {@snippet lang=java : + * out.write(csq.toString()) + * } * *

Depending on the specification of {@code toString} for the * character sequence {@code csq}, the entire sequence may not be @@ -184,8 +185,9 @@ public class CharArrayWriter extends Writer { * {@code csq} is not {@code null}, behaves in * exactly the same way as the invocation * - *

-     *     out.write(csq.subSequence(start, end).toString()) 
+ * {@snippet lang=java : + * out.write(csq.subSequence(start, end).toString()) + * } * * @param csq * The character sequence from which a subsequence will be @@ -220,8 +222,9 @@ public class CharArrayWriter extends Writer { *

An invocation of this method of the form {@code out.append(c)} * behaves in exactly the same way as the invocation * - *

-     *     out.write(c) 
+ * {@snippet lang=java : + * out.write(c) + * } * * @param c * The 16-bit character to append diff --git a/src/java.base/share/classes/java/io/Console.java b/src/java.base/share/classes/java/io/Console.java index d821a476dc7..d6673861f69 100644 --- a/src/java.base/share/classes/java/io/Console.java +++ b/src/java.base/share/classes/java/io/Console.java @@ -86,7 +86,7 @@ import sun.security.action.GetPropertyAction; * char[] passwd; * if ((cons = System.console()) != null && * (passwd = cons.readPassword("[%s]", "Password:")) != null) { - * ... + * code: // @replace substring="code:" replacement="..." * java.util.Arrays.fill(passwd, ' '); * } * } @@ -117,13 +117,13 @@ public sealed class Console implements Flushable permits ProxyingConsole { * This method is intended to be used by sophisticated applications, for * example, a {@link java.util.Scanner} object which utilizes the rich * parsing/scanning functionality provided by the {@code Scanner}: - *
-     * Console con = System.console();
-     * if (con != null) {
-     *     Scanner sc = new Scanner(con.reader());
-     *     ...
+     * {@snippet lang=java :
+     *     Console con = System.console();
+     *     if (con != null) {
+     *         Scanner sc = new Scanner(con.reader());
+     *         code: // @replace substring="code:" replacement="..."
+     *     }
      * }
-     * 
*

* For simple applications requiring only line-oriented reading, use * {@link #readLine}. @@ -186,7 +186,9 @@ public sealed class Console implements Flushable permits ProxyingConsole { *

An invocation of this method of the form * {@code con.printf(format, args)} behaves in exactly the same way * as the invocation of - *

con.format(format, args)
. + * {@snippet lang=java : + * con.format(format, args) + * } * * @param format * A format string as described in An invocation of this method of the form {@code file.setWritable(arg)} * behaves in exactly the same way as the invocation * - *
{@code
+     * {@snippet lang=java :
      *     file.setWritable(arg, true)
-     * }
+ * } * * @param writable * If {@code true}, sets the access permission to allow write @@ -1667,9 +1667,9 @@ public class File *

An invocation of this method of the form {@code file.setReadable(arg)} * behaves in exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     file.setReadable(arg, true)
-     * }
+ * } * * @param readable * If {@code true}, sets the access permission to allow read @@ -1749,9 +1749,9 @@ public class File *

An invocation of this method of the form {@code file.setExcutable(arg)} * behaves in exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     file.setExecutable(arg, true)
-     * }
+ * } * * @param executable * If {@code true}, sets the access permission to allow execute @@ -2370,10 +2370,10 @@ public class File * *

The first invocation of this method works as if invoking it were * equivalent to evaluating the expression: - *

-     * {@link java.nio.file.FileSystems#getDefault FileSystems.getDefault}().{@link
-     * java.nio.file.FileSystem#getPath getPath}(this.{@link #getPath getPath}());
-     * 
+ * {@snippet lang=java : + * // @link regex="getPath(?=\(t)" target="java.nio.file.FileSystem#getPath" : + * FileSystems.getDefault().getPath(this.getPath()); + * } * Subsequent invocations of this method return the same {@code Path}. * *

If this abstract pathname is the empty abstract pathname then this diff --git a/src/java.base/share/classes/java/io/FilePermission.java b/src/java.base/share/classes/java/io/FilePermission.java index e66c155c75b..7c07c608171 100644 --- a/src/java.base/share/classes/java/io/FilePermission.java +++ b/src/java.base/share/classes/java/io/FilePermission.java @@ -1030,7 +1030,7 @@ public final class FilePermission extends Permission implements Serializable { *

and you are calling the {@code implies} method with the FilePermission: * *

-     *   "/tmp/scratch/foo", "read,write",
+     *     "/tmp/scratch/foo", "read,write",
      * 
* * then the {@code implies} function must diff --git a/src/java.base/share/classes/java/io/InputStream.java b/src/java.base/share/classes/java/io/InputStream.java index a2f309323ce..736b6ebd904 100644 --- a/src/java.base/share/classes/java/io/InputStream.java +++ b/src/java.base/share/classes/java/io/InputStream.java @@ -201,7 +201,10 @@ public abstract class InputStream implements Closeable { * * @implSpec * The {@code read(b)} method for class {@code InputStream} - * has the same effect as:
{@code  read(b, 0, b.length) }
+ * has the same effect as: + * {@snippet lang=java : + * read(b, 0, b.length) + * } * * @param b the buffer into which the data is read. * @return the total number of bytes read into the buffer, or diff --git a/src/java.base/share/classes/java/io/InputStreamReader.java b/src/java.base/share/classes/java/io/InputStreamReader.java index d61b3f40fe4..95234cc303b 100644 --- a/src/java.base/share/classes/java/io/InputStreamReader.java +++ b/src/java.base/share/classes/java/io/InputStreamReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, 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 @@ -47,10 +47,9 @@ import sun.nio.cs.StreamDecoder; *

For top efficiency, consider wrapping an InputStreamReader within a * BufferedReader. For example: * - *

- * BufferedReader in
- *   = new BufferedReader(new InputStreamReader(anInputStream));
- * 
+ * {@snippet lang=java : + * BufferedReader in = new BufferedReader(new InputStreamReader(anInputStream)); + * } * * @see BufferedReader * @see InputStream diff --git a/src/java.base/share/classes/java/io/OutputStreamWriter.java b/src/java.base/share/classes/java/io/OutputStreamWriter.java index 78464b50cd5..bcb132e690c 100644 --- a/src/java.base/share/classes/java/io/OutputStreamWriter.java +++ b/src/java.base/share/classes/java/io/OutputStreamWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, 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 @@ -46,10 +46,9 @@ import sun.nio.cs.StreamEncoder; *

For top efficiency, consider wrapping an OutputStreamWriter within a * BufferedWriter so as to avoid frequent converter invocations. For example: * - *

- * Writer out
- *   = new BufferedWriter(new OutputStreamWriter(anOutputStream));
- * 
+ * {@snippet lang=java : + * Writer out = new BufferedWriter(new OutputStreamWriter(anOutputStream)); + * } * *

A surrogate pair is a character represented by a sequence of two * {@code char} values: A high surrogate in the range '\uD800' to diff --git a/src/java.base/share/classes/java/io/PipedInputStream.java b/src/java.base/share/classes/java/io/PipedInputStream.java index 68b5b586d88..21ece8578f8 100644 --- a/src/java.base/share/classes/java/io/PipedInputStream.java +++ b/src/java.base/share/classes/java/io/PipedInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2023, 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 @@ -175,11 +175,15 @@ public class PipedInputStream extends InputStream { * is an unconnected piped input stream, they * may be connected by either the call: * - *

{@code snk.connect(src)} 
+ * {@snippet lang=java : + * snk.connect(src) + * } *

* or the call: * - *

{@code src.connect(snk)} 
+ * {@snippet lang=java : + * src.connect(snk) + * } *

* The two calls have the same effect. * diff --git a/src/java.base/share/classes/java/io/PipedOutputStream.java b/src/java.base/share/classes/java/io/PipedOutputStream.java index 6a8acd5803e..525a4c73996 100644 --- a/src/java.base/share/classes/java/io/PipedOutputStream.java +++ b/src/java.base/share/classes/java/io/PipedOutputStream.java @@ -82,11 +82,13 @@ public class PipedOutputStream extends OutputStream { * If {@code snk} is an unconnected piped input stream and * {@code src} is an unconnected piped output stream, they may * be connected by either the call: - *

-     * src.connect(snk)
+ * {@snippet lang=java : + * src.connect(snk) + * } * or the call: - *
-     * snk.connect(src)
+ * {@snippet lang=java : + * snk.connect(src) + * } * The two calls have the same effect. * * @param snk the piped input stream to connect to. diff --git a/src/java.base/share/classes/java/io/PipedReader.java b/src/java.base/share/classes/java/io/PipedReader.java index fe4cee4ee12..fa34dfdd901 100644 --- a/src/java.base/share/classes/java/io/PipedReader.java +++ b/src/java.base/share/classes/java/io/PipedReader.java @@ -146,11 +146,15 @@ public class PipedReader extends Reader { * is an unconnected piped reader, they * may be connected by either the call: * - *
{@code snk.connect(src)} 
+ * {@snippet lang=java : + * snk.connect(src) + * } *

* or the call: * - *

{@code src.connect(snk)} 
+ * {@snippet lang=java : + * src.connect(snk) + * } *

* The two calls have the same effect. * diff --git a/src/java.base/share/classes/java/io/PipedWriter.java b/src/java.base/share/classes/java/io/PipedWriter.java index f7fed843386..0e98f4ed9e2 100644 --- a/src/java.base/share/classes/java/io/PipedWriter.java +++ b/src/java.base/share/classes/java/io/PipedWriter.java @@ -80,11 +80,13 @@ public class PipedWriter extends Writer { * If {@code snk} is an unconnected piped reader and * {@code src} is an unconnected piped writer, they may * be connected by either the call: - *

-     * src.connect(snk)
+ * {@snippet lang=java : + * src.connect(snk) + * } * or the call: - *
-     * snk.connect(src)
+ * {@snippet lang=java : + * snk.connect(src) + * } * The two calls have the same effect. * * @param snk the piped reader to connect to. diff --git a/src/java.base/share/classes/java/io/PrintStream.java b/src/java.base/share/classes/java/io/PrintStream.java index 194f6e82d4a..1f13c839ff6 100644 --- a/src/java.base/share/classes/java/io/PrintStream.java +++ b/src/java.base/share/classes/java/io/PrintStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, 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 @@ -1206,9 +1206,9 @@ public class PrintStream extends FilterOutputStream * {@code out.printf(format, args)} behaves * in exactly the same way as the invocation * - *
{@code
+     * {@snippet lang=java :
      *     out.format(format, args)
-     * }
+ * } * * @param format * A format string as described in
{@code + * {@snippet lang=java : * out.format(l, format, args) - * } + * } * * @param l * The {@linkplain java.util.Locale locale} to apply during @@ -1442,9 +1442,9 @@ public class PrintStream extends FilterOutputStream *

An invocation of this method of the form {@code out.append(csq)} * behaves in exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.print(csq.toString())
-     * }
+ * } * *

Depending on the specification of {@code toString} for the * character sequence {@code csq}, the entire sequence may not be @@ -1475,9 +1475,9 @@ public class PrintStream extends FilterOutputStream * {@code csq} is not {@code null}, behaves in * exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.print(csq.subSequence(start, end).toString())
-     * }
+ * } * * @param csq * The character sequence from which a subsequence will be @@ -1512,9 +1512,9 @@ public class PrintStream extends FilterOutputStream *

An invocation of this method of the form {@code out.append(c)} * behaves in exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.print(c)
-     * }
+ * } * * @param c * The 16-bit character to append diff --git a/src/java.base/share/classes/java/io/PrintWriter.java b/src/java.base/share/classes/java/io/PrintWriter.java index 667e6c92337..cb7f611f147 100644 --- a/src/java.base/share/classes/java/io/PrintWriter.java +++ b/src/java.base/share/classes/java/io/PrintWriter.java @@ -1045,9 +1045,9 @@ public class PrintWriter extends Writer { * {@code out.printf(format, args)} * behaves in exactly the same way as the invocation * - *
{@code
+     * {@snippet lang=java :
      *     out.format(format, args)
-     * }
+ * } * * @param format * A format string as described in
{@code + * {@snippet lang=java : * out.format(l, format, args) - * } + * } * * @param l * The {@linkplain java.util.Locale locale} to apply during @@ -1289,9 +1289,9 @@ public class PrintWriter extends Writer { *

An invocation of this method of the form {@code out.append(csq)} * behaves in exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.write(csq.toString())
-     * }
+ * } * *

Depending on the specification of {@code toString} for the * character sequence {@code csq}, the entire sequence may not be @@ -1321,9 +1321,9 @@ public class PrintWriter extends Writer { * when {@code csq} is not {@code null}, behaves in * exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.write(csq.subSequence(start, end).toString())
-     * }
+ * } * * @param csq * The character sequence from which a subsequence will be @@ -1358,9 +1358,9 @@ public class PrintWriter extends Writer { *

An invocation of this method of the form {@code out.append(c)} * behaves in exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.write(c)
-     * }
+ * } * * @param c * The 16-bit character to append diff --git a/src/java.base/share/classes/java/io/RandomAccessFile.java b/src/java.base/share/classes/java/io/RandomAccessFile.java index 57f984ad9c4..0be326b0a44 100644 --- a/src/java.base/share/classes/java/io/RandomAccessFile.java +++ b/src/java.base/share/classes/java/io/RandomAccessFile.java @@ -758,9 +758,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * If the byte read is {@code b}, where * {@code 0 <= b <= 255}, * then the result is: - *
+     * {@snippet lang=java :
      *     (byte)(b)
-     * 
+ * } *

* This method blocks until the byte is read, the end of the stream * is detected, or an exception is thrown. @@ -801,9 +801,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * {@code b1} and {@code b2}, where each of the two values is * between {@code 0} and {@code 255}, inclusive, then the * result is equal to: - *

-     *     (short)((b1 << 8) | b2)
-     * 
+ * {@snippet lang=java : + * (short)((b1 << 8) | b2) + * } *

* This method blocks until the two bytes are read, the end of the * stream is detected, or an exception is thrown. @@ -825,9 +825,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * {@code b1} and {@code b2}, where * {@code 0 <= b1, b2 <= 255}, * then the result is equal to: - *

-     *     (b1 << 8) | b2
-     * 
+ * {@snippet lang=java : + * (b1 << 8) | b2 + * } *

* This method blocks until the two bytes are read, the end of the * stream is detected, or an exception is thrown. @@ -851,9 +851,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * {@code b1} and {@code b2}, where * {@code 0 <= b1, b2 <= 255}, * then the result is equal to: - *

-     *     (char)((b1 << 8) | b2)
-     * 
+ * {@snippet lang=java : + * (char)((b1 << 8) | b2) + * } *

* This method blocks until the two bytes are read, the end of the * stream is detected, or an exception is thrown. @@ -875,9 +875,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * {@code b2}, {@code b3}, and {@code b4}, where * {@code 0 <= b1, b2, b3, b4 <= 255}, * then the result is equal to: - *

-     *     (b1 << 24) | (b2 << 16) + (b3 << 8) + b4
-     * 
+ * {@snippet lang=java : + * (b1 << 24) | (b2 << 16) + (b3 << 8) + b4 + * } *

* This method blocks until the four bytes are read, the end of the * stream is detected, or an exception is thrown. @@ -900,17 +900,17 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * {@code b1}, {@code b2}, {@code b3}, * {@code b4}, {@code b5}, {@code b6}, * {@code b7}, and {@code b8,} where: - *

-     *     0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,
-     * 
+ * {@snippet : + * 0 <= b1, b2, b3, b4, b5, b6, b7, b8 <= 255 + * } *

* then the result is equal to: - *

-     *     ((long)b1 << 56) + ((long)b2 << 48)
-     *     + ((long)b3 << 40) + ((long)b4 << 32)
-     *     + ((long)b5 << 24) + ((long)b6 << 16)
-     *     + ((long)b7 << 8) + b8
-     * 
+ * {@snippet lang=java : + * ((long)b1 << 56) + ((long)b2 << 48) + * + ((long)b3 << 40) + ((long)b4 << 32) + * + ((long)b5 << 24) + ((long)b6 << 16) + * + ((long)b7 << 8) + b8 + * } *

* This method blocks until the eight bytes are read, the end of the * stream is detected, or an exception is thrown. diff --git a/src/java.base/share/classes/java/io/StreamTokenizer.java b/src/java.base/share/classes/java/io/StreamTokenizer.java index e2812ff8787..292e7ff15a8 100644 --- a/src/java.base/share/classes/java/io/StreamTokenizer.java +++ b/src/java.base/share/classes/java/io/StreamTokenizer.java @@ -217,10 +217,10 @@ public class StreamTokenizer { * * @deprecated As of JDK version 1.1, the preferred way to tokenize an * input stream is to convert it into a character stream, for example: - *

-     *   Reader r = new BufferedReader(new InputStreamReader(is));
-     *   StreamTokenizer st = new StreamTokenizer(r);
-     * 
+ * {@snippet lang=java : + * Reader r = new BufferedReader(new InputStreamReader(is)); + * StreamTokenizer st = new StreamTokenizer(r); + * } * * @param is an input stream. * @see java.io.BufferedReader @@ -391,7 +391,7 @@ public class StreamTokenizer { * syntax table of this tokenizer is modified so that each of the twelve * characters: *
-     *      0 1 2 3 4 5 6 7 8 9 . -
+     *     0 1 2 3 4 5 6 7 8 9 . -
      * 
*

* has the "numeric" attribute. @@ -770,7 +770,9 @@ public class StreamTokenizer { *

The precise string returned is unspecified, although the following * example can be considered typical: * - *

Token['a'], line 10
+ *
+     *         Token['a'], line 10
+     * 
* * @return a string representation of the token * @see java.io.StreamTokenizer#nval diff --git a/src/java.base/share/classes/java/io/StringWriter.java b/src/java.base/share/classes/java/io/StringWriter.java index 6bff5e9a4c0..9fdeb5550cb 100644 --- a/src/java.base/share/classes/java/io/StringWriter.java +++ b/src/java.base/share/classes/java/io/StringWriter.java @@ -128,8 +128,9 @@ public class StringWriter extends Writer { *

An invocation of this method of the form {@code out.append(csq)} * behaves in exactly the same way as the invocation * - *

-     *     out.write(csq.toString()) 
+ * {@snippet lang=java : + * out.write(csq.toString()) + * } * *

Depending on the specification of {@code toString} for the * character sequence {@code csq}, the entire sequence may not be @@ -159,9 +160,9 @@ public class StringWriter extends Writer { * is not {@code null}, behaves in * exactly the same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.write(csq.subSequence(start, end).toString())
-     * }
+ * } * * @param csq * The character sequence from which a subsequence will be @@ -196,8 +197,9 @@ public class StringWriter extends Writer { *

An invocation of this method of the form {@code out.append(c)} * behaves in exactly the same way as the invocation * - *

-     *     out.write(c) 
+ * {@snippet lang=java : + * out.write(c) + * } * * @param c * The 16-bit character to append diff --git a/src/java.base/share/classes/java/io/Writer.java b/src/java.base/share/classes/java/io/Writer.java index 9d114744567..4ec95d84a76 100644 --- a/src/java.base/share/classes/java/io/Writer.java +++ b/src/java.base/share/classes/java/io/Writer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, 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 @@ -340,8 +340,9 @@ public abstract class Writer implements Appendable, Closeable, Flushable { *

An invocation of this method of the form {@code out.append(csq)} * behaves in exactly the same way as the invocation * - *

-     *     out.write(csq.toString()) 
+ * {@snippet lang=java : + * out.write(csq.toString()) + * } * *

Depending on the specification of {@code toString} for the * character sequence {@code csq}, the entire sequence may not be @@ -375,9 +376,9 @@ public abstract class Writer implements Appendable, Closeable, Flushable { * is not {@code null} behaves in exactly the * same way as the invocation * - *

{@code
+     * {@snippet lang=java :
      *     out.write(csq.subSequence(start, end).toString())
-     * }
+ * } * * @param csq * The character sequence from which a subsequence will be @@ -415,8 +416,9 @@ public abstract class Writer implements Appendable, Closeable, Flushable { *

An invocation of this method of the form {@code out.append(c)} * behaves in exactly the same way as the invocation * - *

-     *     out.write(c) 
+ * {@snippet lang=java : + * out.write(c) + * } * * @param c * The 16-bit character to append