216 /**
217 * Writes a portion of a string.
218 *
219 * @param str A String
220 * @param off Offset from which to start writing characters
221 * @param len Number of characters to write
222 *
223 * @throws IndexOutOfBoundsException
224 * If {@code off} is negative, or {@code len} is negative,
225 * or {@code off + len} is negative or greater than the length
226 * of the given string
227 *
228 * @throws IOException If an I/O error occurs
229 */
230 public void write(String str, int off, int len) throws IOException {
231 se.write(str, off, len);
232 }
233
234 @Override
235 public Writer append(CharSequence csq, int start, int end) throws IOException {
236 if (csq == null) {
237 write("null".subSequence(start, end).toString());
238 return this;
239 } else {
240 return append(csq.subSequence(start, end));
241 }
242 }
243
244 @Override
245 public Writer append(CharSequence csq) throws IOException {
246 if (csq == null) {
247 se.write("null");
248 } else if (csq instanceof CharBuffer) {
249 se.write((CharBuffer) csq);
250 } else {
251 se.write(csq.toString());
252 }
253 return this;
254 }
255
256 /**
257 * Flushes the stream.
258 *
259 * @exception IOException If an I/O error occurs
260 */
261 public void flush() throws IOException {
262 se.flush();
263 }
264
265 public void close() throws IOException {
266 se.close();
267 }
268 }
|
216 /**
217 * Writes a portion of a string.
218 *
219 * @param str A String
220 * @param off Offset from which to start writing characters
221 * @param len Number of characters to write
222 *
223 * @throws IndexOutOfBoundsException
224 * If {@code off} is negative, or {@code len} is negative,
225 * or {@code off + len} is negative or greater than the length
226 * of the given string
227 *
228 * @throws IOException If an I/O error occurs
229 */
230 public void write(String str, int off, int len) throws IOException {
231 se.write(str, off, len);
232 }
233
234 @Override
235 public Writer append(CharSequence csq, int start, int end) throws IOException {
236 if (csq == null) csq = "null";
237 return append(csq.subSequence(start, end));
238 }
239
240 @Override
241 public Writer append(CharSequence csq) throws IOException {
242 if (csq instanceof CharBuffer) {
243 se.write((CharBuffer) csq);
244 } else {
245 se.write(String.valueOf(csq));
246 }
247 return this;
248 }
249
250 /**
251 * Flushes the stream.
252 *
253 * @exception IOException If an I/O error occurs
254 */
255 public void flush() throws IOException {
256 se.flush();
257 }
258
259 public void close() throws IOException {
260 se.close();
261 }
262 }
|