- ensurec(256);
- int numread = reader.read(cbuf, cend, cbuf.length - cend);
- if (numread == -1) {
- if (cstart == cend) return null;
- String ret = new String(cbuf, cstart, cend-cstart);
- cstart = cend = 0;
- return ret;
- }
- cend += numread;
- }
- } catch (IOException e) { ioe(e); return null; } }
-
- public int read(char[] c, int pos, int len) { try {
- if (cstart == cend) {
- cstart = 0;
- cend = reader.read(cbuf, 0, cbuf.length);
- if (cend == -1) { cend = cstart; return -1; }
- }
- if (len > cend - cstart) len = cend - cstart;
- System.arraycopy(cbuf, cstart, c, pos, len);
- cstart += len;
- return len;
- } catch (IOException e) { ioe(e); return -1; } }
-
- public int readBytes(byte[] b, int pos, int len) { flushchars(); return read(b, pos, len); }
- public int read() { byte[] b = new byte[1]; if (read(b, 0, 1) == -1) return -1; return (int)b[0]; }
- public int read(byte[] b, int pos, int len) { try {
- if (start == end) {
- start = 0;
- end = orig.read(buf, 0, buf.length);
- if (end == -1) { end = start; return -1; }
- }
- if (len > end - start) len = end - start;
- System.arraycopy(buf, start, b, pos, len);
- start += len;
- return len;
- } catch (IOException e) { ioe(e); return -1; } }
-
- private void growc(int s){char[] cbuf2=new char[cbuf.length+s*2];System.arraycopy(cbuf,0,cbuf2,0,cbuf.length);cbuf=cbuf2; }
- private void shiftc() {
- char[] cbuf2 = new char[cbuf.length];
- System.arraycopy(cbuf, cstart, cbuf2, 0, cend-cstart);
- cend -= cstart;
- cstart = 0;
- cbuf = cbuf2;