8308016: Use snippets in java.io package

Reviewed-by: rriggs
This commit is contained in:
Brian Burkhalter 2023-05-23 16:00:40 +00:00
parent e9320f31dc
commit 710453c676
20 changed files with 152 additions and 132 deletions

View file

@ -47,10 +47,9 @@ import jdk.internal.misc.InternalLock;
* operations may be costly, such as FileReaders and InputStreamReaders. For * operations may be costly, such as FileReaders and InputStreamReaders. For
* example, * example,
* *
* <pre> * {@snippet lang=java :
* BufferedReader in * BufferedReader in = new BufferedReader(new FileReader("foo.in"));
* = new BufferedReader(new FileReader("foo.in")); * }
* </pre>
* *
* will buffer the input from the specified file. Without buffering, each * will buffer the input from the specified file. Without buffering, each
* invocation of read() or readLine() could cause bytes to be read from the * invocation of read() or readLine() could cause bytes to be read from the

View file

@ -48,10 +48,9 @@ import jdk.internal.misc.VM;
* to wrap a BufferedWriter around any Writer whose write() operations may be * to wrap a BufferedWriter around any Writer whose write() operations may be
* costly, such as FileWriters and OutputStreamWriters. For example, * costly, such as FileWriters and OutputStreamWriters. For example,
* *
* <pre> * {@snippet lang=java :
* PrintWriter out * PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
* = new PrintWriter(new BufferedWriter(new FileWriter("foo.out"))); * }
* </pre>
* *
* will buffer the PrintWriter's output to the file. Without buffering, each * will buffer the PrintWriter's output to the file. Without buffering, each
* invocation of a print() method would cause characters to be converted into * invocation of a print() method would cause characters to be converted into

View file

@ -228,19 +228,17 @@ public class ByteArrayOutputStream extends OutputStream {
* *
* <p> An invocation of this method of the form * <p> An invocation of this method of the form
* *
* <pre> {@code * {@snippet lang=java :
* ByteArrayOutputStream b = ... * ByteArrayOutputStream b;
* b.toString("UTF-8") * b.toString("UTF-8")
* } * }
* </pre>
* *
* behaves in exactly the same way as the expression * behaves in exactly the same way as the expression
* *
* <pre> {@code * {@snippet lang=java :
* ByteArrayOutputStream b = ... * ByteArrayOutputStream b;
* b.toString(StandardCharsets.UTF_8) * b.toString(StandardCharsets.UTF_8)
* } * }
* </pre>
* *
* *
* @param charsetName the name of a supported * @param charsetName the name of a supported
@ -282,9 +280,9 @@ public class ByteArrayOutputStream extends OutputStream {
* copied into it. Each character <i>c</i> in the resulting string is * copied into it. Each character <i>c</i> in the resulting string is
* constructed from the corresponding element <i>b</i> in the byte * constructed from the corresponding element <i>b</i> in the byte
* array such that: * array such that:
* <blockquote><pre>{@code * {@snippet lang=java :
* c == (char)(((hibyte & 0xff) << 8) | (b & 0xff)) * c == (char)(((hibyte & 0xff) << 8) | (b & 0xff))
* }</pre></blockquote> * }
* *
* @deprecated This method does not properly convert bytes into characters. * @deprecated This method does not properly convert bytes into characters.
* As of JDK&nbsp;1.1, the preferred way to do this is via the * As of JDK&nbsp;1.1, the preferred way to do this is via the

View file

@ -152,8 +152,9 @@ public class CharArrayWriter extends Writer {
* <p> An invocation of this method of the form {@code out.append(csq)} * <p> An invocation of this method of the form {@code out.append(csq)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre> * {@snippet lang=java :
* out.write(csq.toString()) </pre> * out.write(csq.toString())
* }
* *
* <p> Depending on the specification of {@code toString} for the * <p> Depending on the specification of {@code toString} for the
* character sequence {@code csq}, the entire sequence may not be * 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 * {@code csq} is not {@code null}, behaves in
* exactly the same way as the invocation * exactly the same way as the invocation
* *
* <pre> * {@snippet lang=java :
* out.write(csq.subSequence(start, end).toString()) </pre> * out.write(csq.subSequence(start, end).toString())
* }
* *
* @param csq * @param csq
* The character sequence from which a subsequence will be * The character sequence from which a subsequence will be
@ -220,8 +222,9 @@ public class CharArrayWriter extends Writer {
* <p> An invocation of this method of the form {@code out.append(c)} * <p> An invocation of this method of the form {@code out.append(c)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre> * {@snippet lang=java :
* out.write(c) </pre> * out.write(c)
* }
* *
* @param c * @param c
* The 16-bit character to append * The 16-bit character to append

View file

@ -86,7 +86,7 @@ import sun.security.action.GetPropertyAction;
* char[] passwd; * char[] passwd;
* if ((cons = System.console()) != null && * if ((cons = System.console()) != null &&
* (passwd = cons.readPassword("[%s]", "Password:")) != null) { * (passwd = cons.readPassword("[%s]", "Password:")) != null) {
* ... * code: // @replace substring="code:" replacement="..."
* java.util.Arrays.fill(passwd, ' '); * 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 * This method is intended to be used by sophisticated applications, for
* example, a {@link java.util.Scanner} object which utilizes the rich * example, a {@link java.util.Scanner} object which utilizes the rich
* parsing/scanning functionality provided by the {@code Scanner}: * parsing/scanning functionality provided by the {@code Scanner}:
* <blockquote><pre> * {@snippet lang=java :
* Console con = System.console(); * Console con = System.console();
* if (con != null) { * if (con != null) {
* Scanner sc = new Scanner(con.reader()); * Scanner sc = new Scanner(con.reader());
* ... * code: // @replace substring="code:" replacement="..."
* }
* } * }
* </pre></blockquote>
* <p> * <p>
* For simple applications requiring only line-oriented reading, use * For simple applications requiring only line-oriented reading, use
* {@link #readLine}. * {@link #readLine}.
@ -186,7 +186,9 @@ public sealed class Console implements Flushable permits ProxyingConsole {
* <p> An invocation of this method of the form * <p> An invocation of this method of the form
* {@code con.printf(format, args)} behaves in exactly the same way * {@code con.printf(format, args)} behaves in exactly the same way
* as the invocation of * as the invocation of
* <pre>con.format(format, args)</pre>. * {@snippet lang=java :
* con.format(format, args)
* }
* *
* @param format * @param format
* A format string as described in <a * A format string as described in <a

View file

@ -1588,9 +1588,9 @@ public class File
* <p> An invocation of this method of the form {@code file.setWritable(arg)} * <p> An invocation of this method of the form {@code file.setWritable(arg)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* file.setWritable(arg, true) * file.setWritable(arg, true)
* }</pre> * }
* *
* @param writable * @param writable
* If {@code true}, sets the access permission to allow write * If {@code true}, sets the access permission to allow write
@ -1667,9 +1667,9 @@ public class File
* <p>An invocation of this method of the form {@code file.setReadable(arg)} * <p>An invocation of this method of the form {@code file.setReadable(arg)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* file.setReadable(arg, true) * file.setReadable(arg, true)
* }</pre> * }
* *
* @param readable * @param readable
* If {@code true}, sets the access permission to allow read * If {@code true}, sets the access permission to allow read
@ -1749,9 +1749,9 @@ public class File
* <p>An invocation of this method of the form {@code file.setExcutable(arg)} * <p>An invocation of this method of the form {@code file.setExcutable(arg)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* file.setExecutable(arg, true) * file.setExecutable(arg, true)
* }</pre> * }
* *
* @param executable * @param executable
* If {@code true}, sets the access permission to allow execute * If {@code true}, sets the access permission to allow execute
@ -2370,10 +2370,10 @@ public class File
* *
* <p> The first invocation of this method works as if invoking it were * <p> The first invocation of this method works as if invoking it were
* equivalent to evaluating the expression: * equivalent to evaluating the expression:
* <blockquote><pre> * {@snippet lang=java :
* {@link java.nio.file.FileSystems#getDefault FileSystems.getDefault}().{@link * // @link regex="getPath(?=\(t)" target="java.nio.file.FileSystem#getPath" :
* java.nio.file.FileSystem#getPath getPath}(this.{@link #getPath getPath}()); * FileSystems.getDefault().getPath(this.getPath());
* </pre></blockquote> * }
* Subsequent invocations of this method return the same {@code Path}. * Subsequent invocations of this method return the same {@code Path}.
* *
* <p> If this abstract pathname is the empty abstract pathname then this * <p> If this abstract pathname is the empty abstract pathname then this

View file

@ -1030,7 +1030,7 @@ public final class FilePermission extends Permission implements Serializable {
* <p>and you are calling the {@code implies} method with the FilePermission: * <p>and you are calling the {@code implies} method with the FilePermission:
* *
* <pre> * <pre>
* "/tmp/scratch/foo", "read,write", * "/tmp/scratch/foo", "read,write",
* </pre> * </pre>
* *
* then the {@code implies} function must * then the {@code implies} function must

View file

@ -201,7 +201,10 @@ public abstract class InputStream implements Closeable {
* *
* @implSpec * @implSpec
* The {@code read(b)} method for class {@code InputStream} * The {@code read(b)} method for class {@code InputStream}
* has the same effect as: <pre>{@code read(b, 0, b.length) }</pre> * has the same effect as:
* {@snippet lang=java :
* read(b, 0, b.length)
* }
* *
* @param b the buffer into which the data is read. * @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or * @return the total number of bytes read into the buffer, or

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,10 +47,9 @@ import sun.nio.cs.StreamDecoder;
* <p> For top efficiency, consider wrapping an InputStreamReader within a * <p> For top efficiency, consider wrapping an InputStreamReader within a
* BufferedReader. For example: * BufferedReader. For example:
* *
* <pre> * {@snippet lang=java :
* BufferedReader in * BufferedReader in = new BufferedReader(new InputStreamReader(anInputStream));
* = new BufferedReader(new InputStreamReader(anInputStream)); * }
* </pre>
* *
* @see BufferedReader * @see BufferedReader
* @see InputStream * @see InputStream

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,10 +46,9 @@ import sun.nio.cs.StreamEncoder;
* <p> For top efficiency, consider wrapping an OutputStreamWriter within a * <p> For top efficiency, consider wrapping an OutputStreamWriter within a
* BufferedWriter so as to avoid frequent converter invocations. For example: * BufferedWriter so as to avoid frequent converter invocations. For example:
* *
* <pre> * {@snippet lang=java :
* Writer out * Writer out = new BufferedWriter(new OutputStreamWriter(anOutputStream));
* = new BufferedWriter(new OutputStreamWriter(anOutputStream)); * }
* </pre>
* *
* <p> A <i>surrogate pair</i> is a character represented by a sequence of two * <p> A <i>surrogate pair</i> is a character represented by a sequence of two
* {@code char} values: A <i>high</i> surrogate in the range '&#92;uD800' to * {@code char} values: A <i>high</i> surrogate in the range '&#92;uD800' to

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * is an unconnected piped input stream, they
* may be connected by either the call: * may be connected by either the call:
* *
* <pre>{@code snk.connect(src)} </pre> * {@snippet lang=java :
* snk.connect(src)
* }
* <p> * <p>
* or the call: * or the call:
* *
* <pre>{@code src.connect(snk)} </pre> * {@snippet lang=java :
* src.connect(snk)
* }
* <p> * <p>
* The two calls have the same effect. * The two calls have the same effect.
* *

View file

@ -82,11 +82,13 @@ public class PipedOutputStream extends OutputStream {
* If {@code snk} is an unconnected piped input stream and * If {@code snk} is an unconnected piped input stream and
* {@code src} is an unconnected piped output stream, they may * {@code src} is an unconnected piped output stream, they may
* be connected by either the call: * be connected by either the call:
* <blockquote><pre> * {@snippet lang=java :
* src.connect(snk)</pre></blockquote> * src.connect(snk)
* }
* or the call: * or the call:
* <blockquote><pre> * {@snippet lang=java :
* snk.connect(src)</pre></blockquote> * snk.connect(src)
* }
* The two calls have the same effect. * The two calls have the same effect.
* *
* @param snk the piped input stream to connect to. * @param snk the piped input stream to connect to.

View file

@ -146,11 +146,15 @@ public class PipedReader extends Reader {
* is an unconnected piped reader, they * is an unconnected piped reader, they
* may be connected by either the call: * may be connected by either the call:
* *
* <pre>{@code snk.connect(src)} </pre> * {@snippet lang=java :
* snk.connect(src)
* }
* <p> * <p>
* or the call: * or the call:
* *
* <pre>{@code src.connect(snk)} </pre> * {@snippet lang=java :
* src.connect(snk)
* }
* <p> * <p>
* The two calls have the same effect. * The two calls have the same effect.
* *

View file

@ -80,11 +80,13 @@ public class PipedWriter extends Writer {
* If {@code snk} is an unconnected piped reader and * If {@code snk} is an unconnected piped reader and
* {@code src} is an unconnected piped writer, they may * {@code src} is an unconnected piped writer, they may
* be connected by either the call: * be connected by either the call:
* <blockquote><pre> * {@snippet lang=java :
* src.connect(snk)</pre></blockquote> * src.connect(snk)
* }
* or the call: * or the call:
* <blockquote><pre> * {@snippet lang=java :
* snk.connect(src)</pre></blockquote> * snk.connect(src)
* }
* The two calls have the same effect. * The two calls have the same effect.
* *
* @param snk the piped reader to connect to. * @param snk the piped reader to connect to.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * {@code out.printf(format, args)} behaves
* in exactly the same way as the invocation * in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.format(format, args) * out.format(format, args)
* }</pre> * }
* *
* @param format * @param format
* A format string as described in <a * A format string as described in <a
@ -1253,9 +1253,9 @@ public class PrintStream extends FilterOutputStream
* {@code out.printf(l, format, args)} behaves * {@code out.printf(l, format, args)} behaves
* in exactly the same way as the invocation * in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.format(l, format, args) * out.format(l, format, args)
* }</pre> * }
* *
* @param l * @param l
* The {@linkplain java.util.Locale locale} to apply during * The {@linkplain java.util.Locale locale} to apply during
@ -1442,9 +1442,9 @@ public class PrintStream extends FilterOutputStream
* <p> An invocation of this method of the form {@code out.append(csq)} * <p> An invocation of this method of the form {@code out.append(csq)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.print(csq.toString()) * out.print(csq.toString())
* }</pre> * }
* *
* <p> Depending on the specification of {@code toString} for the * <p> Depending on the specification of {@code toString} for the
* character sequence {@code csq}, the entire sequence may not be * 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 * {@code csq} is not {@code null}, behaves in
* exactly the same way as the invocation * exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.print(csq.subSequence(start, end).toString()) * out.print(csq.subSequence(start, end).toString())
* }</pre> * }
* *
* @param csq * @param csq
* The character sequence from which a subsequence will be * The character sequence from which a subsequence will be
@ -1512,9 +1512,9 @@ public class PrintStream extends FilterOutputStream
* <p> An invocation of this method of the form {@code out.append(c)} * <p> An invocation of this method of the form {@code out.append(c)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.print(c) * out.print(c)
* }</pre> * }
* *
* @param c * @param c
* The 16-bit character to append * The 16-bit character to append

View file

@ -1045,9 +1045,9 @@ public class PrintWriter extends Writer {
* {@code out.printf(format, args)} * {@code out.printf(format, args)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.format(format, args) * out.format(format, args)
* }</pre> * }
* *
* @param format * @param format
* A format string as described in <a * A format string as described in <a
@ -1093,9 +1093,9 @@ public class PrintWriter extends Writer {
* {@code out.printf(l, format, args)} * {@code out.printf(l, format, args)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.format(l, format, args) * out.format(l, format, args)
* }</pre> * }
* *
* @param l * @param l
* The {@linkplain java.util.Locale locale} to apply during * The {@linkplain java.util.Locale locale} to apply during
@ -1289,9 +1289,9 @@ public class PrintWriter extends Writer {
* <p> An invocation of this method of the form {@code out.append(csq)} * <p> An invocation of this method of the form {@code out.append(csq)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.write(csq.toString()) * out.write(csq.toString())
* }</pre> * }
* *
* <p> Depending on the specification of {@code toString} for the * <p> Depending on the specification of {@code toString} for the
* character sequence {@code csq}, the entire sequence may not be * 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 * when {@code csq} is not {@code null}, behaves in
* exactly the same way as the invocation * exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.write(csq.subSequence(start, end).toString()) * out.write(csq.subSequence(start, end).toString())
* }</pre> * }
* *
* @param csq * @param csq
* The character sequence from which a subsequence will be * The character sequence from which a subsequence will be
@ -1358,9 +1358,9 @@ public class PrintWriter extends Writer {
* <p> An invocation of this method of the form {@code out.append(c)} * <p> An invocation of this method of the form {@code out.append(c)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.write(c) * out.write(c)
* }</pre> * }
* *
* @param c * @param c
* The 16-bit character to append * The 16-bit character to append

View file

@ -758,9 +758,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* If the byte read is {@code b}, where * If the byte read is {@code b}, where
* {@code 0 <= b <= 255}, * {@code 0 <= b <= 255},
* then the result is: * then the result is:
* <blockquote><pre> * {@snippet lang=java :
* (byte)(b) * (byte)(b)
* </pre></blockquote> * }
* <p> * <p>
* This method blocks until the byte is read, the end of the stream * This method blocks until the byte is read, the end of the stream
* is detected, or an exception is thrown. * 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 * {@code b1} and {@code b2}, where each of the two values is
* between {@code 0} and {@code 255}, inclusive, then the * between {@code 0} and {@code 255}, inclusive, then the
* result is equal to: * result is equal to:
* <blockquote><pre> * {@snippet lang=java :
* (short)((b1 &lt;&lt; 8) | b2) * (short)((b1 << 8) | b2)
* </pre></blockquote> * }
* <p> * <p>
* This method blocks until the two bytes are read, the end of the * This method blocks until the two bytes are read, the end of the
* stream is detected, or an exception is thrown. * 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 b1} and {@code b2}, where
* {@code 0 <= b1, b2 <= 255}, * {@code 0 <= b1, b2 <= 255},
* then the result is equal to: * then the result is equal to:
* <blockquote><pre> * {@snippet lang=java :
* (b1 &lt;&lt; 8) | b2 * (b1 << 8) | b2
* </pre></blockquote> * }
* <p> * <p>
* This method blocks until the two bytes are read, the end of the * This method blocks until the two bytes are read, the end of the
* stream is detected, or an exception is thrown. * 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 b1} and {@code b2}, where
* {@code 0 <= b1, b2 <= 255}, * {@code 0 <= b1, b2 <= 255},
* then the result is equal to: * then the result is equal to:
* <blockquote><pre> * {@snippet lang=java :
* (char)((b1 &lt;&lt; 8) | b2) * (char)((b1 << 8) | b2)
* </pre></blockquote> * }
* <p> * <p>
* This method blocks until the two bytes are read, the end of the * This method blocks until the two bytes are read, the end of the
* stream is detected, or an exception is thrown. * 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 b2}, {@code b3}, and {@code b4}, where
* {@code 0 <= b1, b2, b3, b4 <= 255}, * {@code 0 <= b1, b2, b3, b4 <= 255},
* then the result is equal to: * then the result is equal to:
* <blockquote><pre> * {@snippet lang=java :
* (b1 &lt;&lt; 24) | (b2 &lt;&lt; 16) + (b3 &lt;&lt; 8) + b4 * (b1 << 24) | (b2 << 16) + (b3 << 8) + b4
* </pre></blockquote> * }
* <p> * <p>
* This method blocks until the four bytes are read, the end of the * This method blocks until the four bytes are read, the end of the
* stream is detected, or an exception is thrown. * 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 b1}, {@code b2}, {@code b3},
* {@code b4}, {@code b5}, {@code b6}, * {@code b4}, {@code b5}, {@code b6},
* {@code b7}, and {@code b8,} where: * {@code b7}, and {@code b8,} where:
* <blockquote><pre> * {@snippet :
* 0 &lt;= b1, b2, b3, b4, b5, b6, b7, b8 &lt;=255, * 0 <= b1, b2, b3, b4, b5, b6, b7, b8 <= 255
* </pre></blockquote> * }
* <p> * <p>
* then the result is equal to: * then the result is equal to:
* <blockquote><pre> * {@snippet lang=java :
* ((long)b1 &lt;&lt; 56) + ((long)b2 &lt;&lt; 48) * ((long)b1 << 56) + ((long)b2 << 48)
* + ((long)b3 &lt;&lt; 40) + ((long)b4 &lt;&lt; 32) * + ((long)b3 << 40) + ((long)b4 << 32)
* + ((long)b5 &lt;&lt; 24) + ((long)b6 &lt;&lt; 16) * + ((long)b5 << 24) + ((long)b6 << 16)
* + ((long)b7 &lt;&lt; 8) + b8 * + ((long)b7 << 8) + b8
* </pre></blockquote> * }
* <p> * <p>
* This method blocks until the eight bytes are read, the end of the * This method blocks until the eight bytes are read, the end of the
* stream is detected, or an exception is thrown. * stream is detected, or an exception is thrown.

View file

@ -217,10 +217,10 @@ public class StreamTokenizer {
* *
* @deprecated As of JDK version 1.1, the preferred way to tokenize an * @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: * input stream is to convert it into a character stream, for example:
* <blockquote><pre> * {@snippet lang=java :
* Reader r = new BufferedReader(new InputStreamReader(is)); * Reader r = new BufferedReader(new InputStreamReader(is));
* StreamTokenizer st = new StreamTokenizer(r); * StreamTokenizer st = new StreamTokenizer(r);
* </pre></blockquote> * }
* *
* @param is an input stream. * @param is an input stream.
* @see java.io.BufferedReader * @see java.io.BufferedReader
@ -391,7 +391,7 @@ public class StreamTokenizer {
* syntax table of this tokenizer is modified so that each of the twelve * syntax table of this tokenizer is modified so that each of the twelve
* characters: * characters:
* <blockquote><pre> * <blockquote><pre>
* 0 1 2 3 4 5 6 7 8 9 . - * 0 1 2 3 4 5 6 7 8 9 . -
* </pre></blockquote> * </pre></blockquote>
* <p> * <p>
* has the "numeric" attribute. * has the "numeric" attribute.
@ -770,7 +770,9 @@ public class StreamTokenizer {
* <p>The precise string returned is unspecified, although the following * <p>The precise string returned is unspecified, although the following
* example can be considered typical: * example can be considered typical:
* *
* <blockquote><pre>Token['a'], line 10</pre></blockquote> * <blockquote><pre>
* Token['a'], line 10
* </pre></blockquote>
* *
* @return a string representation of the token * @return a string representation of the token
* @see java.io.StreamTokenizer#nval * @see java.io.StreamTokenizer#nval

View file

@ -128,8 +128,9 @@ public class StringWriter extends Writer {
* <p> An invocation of this method of the form {@code out.append(csq)} * <p> An invocation of this method of the form {@code out.append(csq)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre> * {@snippet lang=java :
* out.write(csq.toString()) </pre> * out.write(csq.toString())
* }
* *
* <p> Depending on the specification of {@code toString} for the * <p> Depending on the specification of {@code toString} for the
* character sequence {@code csq}, the entire sequence may not be * 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 * is not {@code null}, behaves in
* exactly the same way as the invocation * exactly the same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.write(csq.subSequence(start, end).toString()) * out.write(csq.subSequence(start, end).toString())
* }</pre> * }
* *
* @param csq * @param csq
* The character sequence from which a subsequence will be * The character sequence from which a subsequence will be
@ -196,8 +197,9 @@ public class StringWriter extends Writer {
* <p> An invocation of this method of the form {@code out.append(c)} * <p> An invocation of this method of the form {@code out.append(c)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre> * {@snippet lang=java :
* out.write(c) </pre> * out.write(c)
* }
* *
* @param c * @param c
* The 16-bit character to append * The 16-bit character to append

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 {
* <p> An invocation of this method of the form {@code out.append(csq)} * <p> An invocation of this method of the form {@code out.append(csq)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre> * {@snippet lang=java :
* out.write(csq.toString()) </pre> * out.write(csq.toString())
* }
* *
* <p> Depending on the specification of {@code toString} for the * <p> Depending on the specification of {@code toString} for the
* character sequence {@code csq}, the entire sequence may not be * 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 * is not {@code null} behaves in exactly the
* same way as the invocation * same way as the invocation
* *
* <pre>{@code * {@snippet lang=java :
* out.write(csq.subSequence(start, end).toString()) * out.write(csq.subSequence(start, end).toString())
* }</pre> * }
* *
* @param csq * @param csq
* The character sequence from which a subsequence will be * The character sequence from which a subsequence will be
@ -415,8 +416,9 @@ public abstract class Writer implements Appendable, Closeable, Flushable {
* <p> An invocation of this method of the form {@code out.append(c)} * <p> An invocation of this method of the form {@code out.append(c)}
* behaves in exactly the same way as the invocation * behaves in exactly the same way as the invocation
* *
* <pre> * {@snippet lang=java :
* out.write(c) </pre> * out.write(c)
* }
* *
* @param c * @param c
* The 16-bit character to append * The 16-bit character to append