1
1
/*
2
- * Copyright (c) 1996, 2024 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1996, 2025 , 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
@@ -125,20 +125,6 @@ public void write(String str, int off, int len) {
125
125
/**
126
126
* Appends the specified character sequence to this writer.
127
127
*
128
- * <p> An invocation of this method of the form {@code out.append(csq)}
129
- * when {@code csq} is not {@code null}, behaves in exactly the same way
130
- * as the invocation
131
- *
132
- * {@snippet lang=java :
133
- * out.write(csq.toString())
134
- * }
135
- *
136
- * <p> Depending on the specification of {@code toString} for the
137
- * character sequence {@code csq}, the entire sequence may not be
138
- * appended. For instance, invoking the {@code toString} method of a
139
- * character buffer will return a subsequence whose content depends upon
140
- * the buffer's position and limit.
141
- *
142
128
* @param csq
143
129
* The character sequence to append. If {@code csq} is
144
130
* {@code null}, then the four characters {@code "null"} are
@@ -149,22 +135,14 @@ public void write(String str, int off, int len) {
149
135
* @since 1.5
150
136
*/
151
137
public StringWriter append (CharSequence csq ) {
152
- write (String .valueOf (csq ));
138
+ if (csq == null ) csq = "null" ;
139
+ buf .append (csq );
153
140
return this ;
154
141
}
155
142
156
143
/**
157
144
* Appends a subsequence of the specified character sequence to this writer.
158
145
*
159
- * <p> An invocation of this method of the form
160
- * {@code out.append(csq, start, end)} when {@code csq}
161
- * is not {@code null}, behaves in
162
- * exactly the same way as the invocation
163
- *
164
- * {@snippet lang=java :
165
- * out.write(csq.subSequence(start, end).toString())
166
- * }
167
- *
168
146
* @param csq
169
147
* The character sequence from which a subsequence will be
170
148
* appended. If {@code csq} is {@code null}, then characters
@@ -189,7 +167,8 @@ public StringWriter append(CharSequence csq) {
189
167
*/
190
168
public StringWriter append (CharSequence csq , int start , int end ) {
191
169
if (csq == null ) csq = "null" ;
192
- return append (csq .subSequence (start , end ));
170
+ buf .append (csq , start , end );
171
+ return this ;
193
172
}
194
173
195
174
/**
0 commit comments