|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
37 | 37 | * <p> The buffer size may be specified, or the default size may be accepted.
|
38 | 38 | * The default is large enough for most purposes.
|
39 | 39 | *
|
40 |
| - * <p> A newLine() method is provided, which uses the platform's own notion of |
41 |
| - * line separator as defined by the system property {@code line.separator}. |
42 |
| - * Not all platforms use the newline character ('\n') to terminate lines. |
43 |
| - * Calling this method to terminate each output line is therefore preferred to |
44 |
| - * writing a newline character directly. |
| 40 | + * <p> A {@code newLine()} method is provided, which uses the platform's own |
| 41 | + * notion of line separator as defined by the system property |
| 42 | + * {@linkplain System#lineSeparator() line.separator}. Not all platforms use the newline character ('\n') |
| 43 | + * to terminate lines. Calling this method to terminate each output line is |
| 44 | + * therefore preferred to writing a newline character directly. |
45 | 45 | *
|
46 |
| - * <p> In general, a Writer sends its output immediately to the underlying |
47 |
| - * character or byte stream. Unless prompt output is required, it is advisable |
48 |
| - * to wrap a BufferedWriter around any Writer whose write() operations may be |
49 |
| - * costly, such as FileWriters and OutputStreamWriters. For example, |
| 46 | + * <p> In general, a {@code Writer} sends its output immediately to the |
| 47 | + * underlying character or byte stream. Unless prompt output is required, it |
| 48 | + * is advisable to wrap a {@code BufferedWriter} around any {@code Writer} whose |
| 49 | + * {@code write()} operations may be costly, such as {@code FileWriter}s and |
| 50 | + * {@code OutputStreamWriter}s. For example, |
50 | 51 | *
|
51 | 52 | * {@snippet lang=java :
|
52 | 53 | * PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
|
53 | 54 | * }
|
54 | 55 | *
|
55 |
| - * will buffer the PrintWriter's output to the file. Without buffering, each |
56 |
| - * invocation of a print() method would cause characters to be converted into |
57 |
| - * bytes that would then be written immediately to the file, which can be very |
58 |
| - * inefficient. |
| 56 | + * will buffer the {@code PrintWriter}'s output to the file. Without buffering, |
| 57 | + * each invocation of a {@code print()} method would cause characters to be |
| 58 | + * converted into bytes that would then be written immediately to the file, |
| 59 | + * which can be very inefficient. |
| 60 | + * |
| 61 | + * @apiNote |
| 62 | + * Once wrapped in a {@code BufferedWriter}, the underlying |
| 63 | + * {@code Writer} should not be used directly nor wrapped with |
| 64 | + * another writer. |
59 | 65 | *
|
60 | 66 | * @see PrintWriter
|
61 | 67 | * @see FileWriter
|
|
0 commit comments