204 }
205 }
206
207 /**
208 * Appends the specified character sequence to this writer.
209 *
210 * <p> An invocation of this method of the form {@code out.append(csq)}
211 * behaves in exactly the same way as the invocation
212 *
213 * <pre>
214 * out.write(csq.toString()) </pre>
215 *
216 * <p> Depending on the specification of {@code toString} for the
217 * character sequence {@code csq}, the entire sequence may not be
218 * appended. For instance, invoking the {@code toString} method of a
219 * character buffer will return a subsequence whose content depends upon
220 * the buffer's position and limit.
221 *
222 * @param csq
223 * The character sequence to append. If {@code csq} is
224 * {@code null}, then the four characters "{@code null}" are
225 * appended to this writer.
226 *
227 * @return This writer
228 *
229 * @throws IOException
230 * If an I/O error occurs
231 *
232 * @since 1.5
233 */
234 public Writer append(CharSequence csq) throws IOException {
235 if (csq == null)
236 write("null");
237 else
238 write(csq.toString());
239 return this;
240 }
241
242 /**
243 * Appends a subsequence of the specified character sequence to this writer.
244 * {@code Appendable}.
245 *
246 * <p> An invocation of this method of the form
247 * {@code out.append(csq, start, end)} when {@code csq}
248 * is not {@code null} behaves in exactly the
249 * same way as the invocation
250 *
251 * <pre>{@code
252 * out.write(csq.subSequence(start, end).toString())
253 * }</pre>
254 *
255 * @param csq
256 * The character sequence from which a subsequence will be
257 * appended. If {@code csq} is {@code null}, then characters
258 * will be appended as if {@code csq} contained the four
259 * characters "{@code null}".
260 *
261 * @param start
262 * The index of the first character in the subsequence
263 *
264 * @param end
265 * The index of the character following the last character in the
266 * subsequence
267 *
268 * @return This writer
269 *
270 * @throws IndexOutOfBoundsException
271 * If {@code start} or {@code end} are negative, {@code start}
272 * is greater than {@code end}, or {@code end} is greater than
273 * {@code csq.length()}
274 *
275 * @throws IOException
276 * If an I/O error occurs
277 *
278 * @since 1.5
279 */
280 public Writer append(CharSequence csq, int start, int end) throws IOException {
281 CharSequence cs = (csq == null ? "null" : csq);
282 write(cs.subSequence(start, end).toString());
283 return this;
284 }
285
286 /**
287 * Appends the specified character to this writer.
288 *
289 * <p> An invocation of this method of the form {@code out.append(c)}
290 * behaves in exactly the same way as the invocation
291 *
292 * <pre>
293 * out.write(c) </pre>
294 *
295 * @param c
296 * The 16-bit character to append
297 *
298 * @return This writer
299 *
300 * @throws IOException
301 * If an I/O error occurs
302 *
|
204 }
205 }
206
207 /**
208 * Appends the specified character sequence to this writer.
209 *
210 * <p> An invocation of this method of the form {@code out.append(csq)}
211 * behaves in exactly the same way as the invocation
212 *
213 * <pre>
214 * out.write(csq.toString()) </pre>
215 *
216 * <p> Depending on the specification of {@code toString} for the
217 * character sequence {@code csq}, the entire sequence may not be
218 * appended. For instance, invoking the {@code toString} method of a
219 * character buffer will return a subsequence whose content depends upon
220 * the buffer's position and limit.
221 *
222 * @param csq
223 * The character sequence to append. If {@code csq} is
224 * {@code null}, then the four characters {@code "null"} are
225 * appended to this writer.
226 *
227 * @return This writer
228 *
229 * @throws IOException
230 * If an I/O error occurs
231 *
232 * @since 1.5
233 */
234 public Writer append(CharSequence csq) throws IOException {
235 write(String.valueOf(csq));
236 return this;
237 }
238
239 /**
240 * Appends a subsequence of the specified character sequence to this writer.
241 * {@code Appendable}.
242 *
243 * <p> An invocation of this method of the form
244 * {@code out.append(csq, start, end)} when {@code csq}
245 * is not {@code null} behaves in exactly the
246 * same way as the invocation
247 *
248 * <pre>{@code
249 * out.write(csq.subSequence(start, end).toString())
250 * }</pre>
251 *
252 * @param csq
253 * The character sequence from which a subsequence will be
254 * appended. If {@code csq} is {@code null}, then characters
255 * will be appended as if {@code csq} contained the four
256 * characters {@code "null"}.
257 *
258 * @param start
259 * The index of the first character in the subsequence
260 *
261 * @param end
262 * The index of the character following the last character in the
263 * subsequence
264 *
265 * @return This writer
266 *
267 * @throws IndexOutOfBoundsException
268 * If {@code start} or {@code end} are negative, {@code start}
269 * is greater than {@code end}, or {@code end} is greater than
270 * {@code csq.length()}
271 *
272 * @throws IOException
273 * If an I/O error occurs
274 *
275 * @since 1.5
276 */
277 public Writer append(CharSequence csq, int start, int end) throws IOException {
278 if (csq == null) csq = "null";
279 write(csq.subSequence(start, end).toString());
280 return this;
281 }
282
283 /**
284 * Appends the specified character to this writer.
285 *
286 * <p> An invocation of this method of the form {@code out.append(c)}
287 * behaves in exactly the same way as the invocation
288 *
289 * <pre>
290 * out.write(c) </pre>
291 *
292 * @param c
293 * The 16-bit character to append
294 *
295 * @return This writer
296 *
297 * @throws IOException
298 * If an I/O error occurs
299 *
|