MCPcopy Create free account
hub / github.com/davidgiven/luje / write

Method write

lib/java/io/BufferedWriter.java:192–229  ·  view source on GitHub ↗

Writes count characters starting at offset in cbuf to this writer. If count is greater than this writer's buffer, then the buffer is flushed and the characters are written directly to the target writer. @param cbuf the array containing characters to write.

(char[] cbuf, int offset, int count)

Source from the content-addressed store, hash-verified

190 * if this writer is closed or another I/O error occurs.
191 */
192 @Override
193 public void write(char[] cbuf, int offset, int count) throws IOException {
194 synchronized (lock) {
195 if (isClosed()) {
196 throw new IOException(Messages.getString("luni.A7")); //$NON-NLS-1$
197 }
198 if (offset < 0 || offset > cbuf.length - count || count < 0) {
199 throw new IndexOutOfBoundsException();
200 }
201 if (pos == 0 && count >= this.buf.length) {
202 out.write(cbuf, offset, count);
203 return;
204 }
205 int available = this.buf.length - pos;
206 if (count < available) {
207 available = count;
208 }
209 if (available > 0) {
210 System.arraycopy(cbuf, offset, this.buf, pos, available);
211 pos += available;
212 }
213 if (pos == this.buf.length) {
214 out.write(this.buf, 0, this.buf.length);
215 pos = 0;
216 if (count > available) {
217 offset += available;
218 available = count - available;
219 if (available >= this.buf.length) {
220 out.write(cbuf, offset, available);
221 return;
222 }
223
224 System.arraycopy(cbuf, offset, this.buf, pos, available);
225 pos += available;
226 }
227 }
228 }
229 }
230
231 /**
232 * Writes the character {@code oneChar} to this writer. If the buffer

Callers 1

newLineMethod · 0.95

Calls 6

isClosedMethod · 0.95
getStringMethod · 0.95
arraycopyMethod · 0.95
writeMethod · 0.65
lengthMethod · 0.65
getCharsMethod · 0.45

Tested by

no test coverage detected