- *
- * @return TRUE if it is
- */
- public boolean eof() {
- return closed || (len < 0 && !hasMoreData());
- }
-
- @Override
- public int read() throws IOException {
- checkClose();
-
- preRead();
- if (eof) {
- return -1;
- }
-
- return buffer[pos++];
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- @Override
- public int read(byte[] b, int boff, int blen) throws IOException {
- checkClose();
-
- if (b == null) {
- throw new NullPointerException();
- } else if (boff < 0 || blen < 0 || blen > b.length - boff) {
- throw new IndexOutOfBoundsException();
- } else if (blen == 0) {
- return 0;
- }
-
- int done = 0;
- while (hasMoreData() && done < blen) {
- preRead();
- if (hasMoreData()) {
- for (int i = pos; i < blen && i < len; i++) {
- b[boff + done] = buffer[i];
- pos++;
- done++;
- }
- }
- }
-
- return done > 0 ? done : -1;
- }
-
- @Override
- public long skip(long n) throws IOException {
- // TODO Auto-generated method stub
- return super.skip(n);
- }
-
- @Override
- public int available() {
- if (closed) {
- return 0;
- }
-
- return Math.max(0, len - pos);
- }
-
- /**
- * Closes this stream and releases any system resources associated with the
- * stream.
- * <p>
- * Including the under-laying {@link InputStream}.