private char[] getBuffer(int additional) throws IOException {
		long newLen = (long)length + additional;
		if(newLen > MAX_LENGTH) throw new IOException("Maximum buffer length is " + MAX_LENGTH + ", " + newLen + " requested");
		char[] buf = this.buffer;
		int bufLen = buf.length;
		if(newLen > bufLen) {
			// Find the next power of two that will hold all of the contents
			int newBufLen = bufLen==0 ? BufferManager.BUFFER_SIZE : (bufLen << 1);
			while(newBufLen < newLen) {
				newBufLen <<= 1;
			}
			char[] newBuf =
				(newBufLen == BufferManager.BUFFER_SIZE)
				? BufferManager.getChars()
				: new char[newBufLen];
			System.arraycopy(buf, 0, newBuf, 0, length);
			// Recycle buffer
			if(bufLen == BufferManager.BUFFER_SIZE) {
				BufferManager.release(buf, false);
			}
			buf = newBuf;
			this.buffer = buf;
		}
		return buf;
	}
private char[] getBuffer(int additional) throws IOException {
		long newLen = (long)length + additional;
		if(newLen > MAX_LENGTH) throw new IOException("Maximum buffer length is " + MAX_LENGTH + ", " + newLen + " requested");
		char[] buf = this.buffer;
		int bufLen = buf.length;
		if(newLen > bufLen) {
			
			int newBufLen = bufLen==0 ? BufferManager.BUFFER_SIZE : (bufLen << 1);
			while(newBufLen < newLen) {
				newBufLen <<= 1;
			}
			char[] newBuf =
				(newBufLen == BufferManager.BUFFER_SIZE)
				? BufferManager.getChars()
				: new char[newBufLen];
			System.arraycopy(buf, 0, newBuf, 0, length);
			
			if(bufLen == BufferManager.BUFFER_SIZE) {
				BufferManager.release(buf, false);
			}
			buf = newBuf;
			this.buffer = buf;
		}
		return buf;
	}
private char [ ] getBuffer ( int additional ) throws IOException { long newLen = ( long ) length + additional ; if ( newLen > MAX_LENGTH ) throw new IOException ( "Maximum buffer length is " + MAX_LENGTH + ", " + newLen + " requested" ) ; char [ ] buf = this . buffer ; int bufLen = buf . length ; if ( newLen > bufLen ) { // Find the next power of two that will hold all of the contents int newBufLen = bufLen == 0 ? BufferManager . BUFFER_SIZE : ( bufLen << 1 ) ; while ( newBufLen < newLen ) { newBufLen <<= 1 ; } char [ ] newBuf = ( newBufLen == BufferManager . BUFFER_SIZE ) ? BufferManager . getChars ( ) : new char [ newBufLen ] ; System . arraycopy ( buf , 0 , newBuf , 0 , length ) ; // Recycle buffer if ( bufLen == BufferManager . BUFFER_SIZE ) { BufferManager . release ( buf , false ) ; } buf = newBuf ; this . buffer = buf ; } return buf ; }
Grows as-needed to fit the provided new capacity.

@returns the possibly new buffer.
Grows as - needed to fit the provided new capacity .