public Appendable append(char c) throws IOException { ensure(1); chars[to++] = c; return this; } }
public Appendable append(char c) throws IOException { ensure(1); chars[to++] = c; return this; } }
public Appendable append(CharSequence csq, int start, int end) throws IOException { if (start < 0) { throw new IndexOutOfBoundsException("Start " + start + " cannot be negative"); } if (start > end) { throw new IndexOutOfBoundsException("Start " + start + " cannot be greater then end " + end); } if (end > csq.length()) { throw new IndexOutOfBoundsException("End " + end + " cannot be greater then char sequence " + csq.length()); } int len = end - start; ensure(len); while (start < end) { chars[to++] = csq.charAt(start++); } return this; }
public Appendable append(CharSequence csq, int start, int end) throws IOException { if (start < 0) { throw new IndexOutOfBoundsException("Start " + start + " cannot be negative"); } if (start > end) { throw new IndexOutOfBoundsException("Start " + start + " cannot be greater then end " + end); } if (end > csq.length()) { throw new IndexOutOfBoundsException("End " + end + " cannot be greater then char sequence " + csq.length()); } int len = end - start; ensure(len); while (start < end) { chars[to++] = csq.charAt(start++); } return this; }
/** * Read from a char array. * * @param src the char array source * @param at the first index of the chars to read * @param len the amount of chars to read * @throws NullPointerException if the source is null * @throws IllegalArgumentException if the len argument is negative * @throws IndexOutOfBoundsException if the source is adressed out of its bounds */ public void readFrom(char[] src, int at, int len) throws NullPointerException, IllegalArgumentException, IndexOutOfBoundsException { if (src == null) { throw new NullPointerException("Buffer cannot be null"); } if (at < 0) { throw new IndexOutOfBoundsException("Begin pointer cannot be negative: " + at); } if (len < 0) { throw new IllegalArgumentException("Length cannot be negative: " + len); } if (at + len > src.length) { throw new IndexOutOfBoundsException("End pointer cannot be greater than buffer: " + (at + len)); } // Check if we have enough remaining space ensure(len); // Copy data System.arraycopy(src, at, this.chars, to, len); to += len; }
/** * Read from a char array. * * @param src the char array source * @param at the first index of the chars to read * @param len the amount of chars to read * @throws NullPointerException if the source is null * @throws IllegalArgumentException if the len argument is negative * @throws IndexOutOfBoundsException if the source is adressed out of its bounds */ public void readFrom(char[] src, int at, int len) throws NullPointerException, IllegalArgumentException, IndexOutOfBoundsException { if (src == null) { throw new NullPointerException("Buffer cannot be null"); } if (at < 0) { throw new IndexOutOfBoundsException("Begin pointer cannot be negative: " + at); } if (len < 0) { throw new IllegalArgumentException("Length cannot be negative: " + len); } if (at + len > src.length) { throw new IndexOutOfBoundsException("End pointer cannot be greater than buffer: " + (at + len)); } // Check if we have enough remaining space ensure(len); // Copy data System.arraycopy(src, at, this.chars, to, len); to += len; }