|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2001, 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
|
@@ -123,13 +123,12 @@ public void write(char[] cbuf, int off, int len) throws IOException {
|
123 | 123 | }
|
124 | 124 | }
|
125 | 125 |
|
| 126 | + public void write(CharSequence csq, int off, int len) throws IOException { |
| 127 | + implWrite(csq, off, len); |
| 128 | + } |
| 129 | + |
126 | 130 | public void write(String str, int off, int len) throws IOException {
|
127 |
| - /* Check the len before creating a char buffer */ |
128 |
| - if (len < 0) |
129 |
| - throw new IndexOutOfBoundsException(); |
130 |
| - char[] cbuf = new char[len]; |
131 |
| - str.getChars(off, off + len, cbuf, 0); |
132 |
| - write(cbuf, 0, len); |
| 131 | + implWrite(str, off, len); |
133 | 132 | }
|
134 | 133 |
|
135 | 134 | public void write(CharBuffer cb) throws IOException {
|
@@ -260,6 +259,15 @@ private void flushLeftoverChar(CharBuffer cb, boolean endOfInput)
|
260 | 259 | haveLeftoverChar = false;
|
261 | 260 | }
|
262 | 261 |
|
| 262 | + void implWrite(CharSequence csq, int off, int len) throws IOException { |
| 263 | + /* Check the len before creating a char buffer */ |
| 264 | + if (len < 0) |
| 265 | + throw new IndexOutOfBoundsException(); |
| 266 | + char[] cbuf = new char[len]; |
| 267 | + csq.getChars(off, off + len, cbuf, 0); |
| 268 | + write(cbuf, 0, len); |
| 269 | + } |
| 270 | + |
263 | 271 | void implWrite(char[] cbuf, int off, int len)
|
264 | 272 | throws IOException
|
265 | 273 | {
|
|
0 commit comments