FileDocCategorySizeDatePackage
DumpFilter.javaAPI DocExample2420Sat Feb 04 06:07:04 GMT 2006com.elharo.io

DumpFilter

public abstract class DumpFilter extends FilterInputStream

Fields Summary
private int[]
buf
private int
index
Constructors Summary
public DumpFilter(InputStream in)

  
     
    super(in);
  
Methods Summary
public intavailable()

    return buf.length - index;
  
protected abstract voidfill()

public voidmark(int readlimit)

public booleanmarkSupported()

    return false;
  
public intread()

  
    int result;
    if (index < buf.length) {
      result = buf[index];
      index++;
    }  // end if
    else {
      try {
        this.fill();
        // fill is required to put at least one byte 
        // in the buffer or throw an EOF or IOException.
        result = buf[0];
        index = 1;
      }
      catch (EOFException ex) {
        result = -1;
      }
    }  // end else
    
    return result;
  
public intread(byte[] data, int offset, int length)

  
    if (data == null) {
      throw new NullPointerException();
    } 
    else if ((offset < 0) || (offset > data.length) || (length < 0) 
     || ((offset + length) > data.length) || ((offset + length) < 0)) {
      throw new ArrayIndexOutOfBoundsException();
    } 
    else if (length == 0) {
      return 0;
    }

    // Check for end of stream.
    int datum = this.read();
    if (datum == -1) {
      return -1;
    }
    
    data[offset] = (byte) datum;

    int bytesRead = 1;
    try {
      for (; bytesRead < length ; bytesRead++) {
      
        datum = this.read();
        
        // In case of end of stream, return as much as we've got,
        // then wait for the next call to read to return -1.
        if (datum == -1) break;
        data[offset + bytesRead] = (byte) datum;
      }
    }
    catch (IOException ex) {
      // Return what's already in the data array.
    }
    return bytesRead;   
  
public voidreset()

    throw new IOException("marking not supported");
  
public longskip(long bytesToSkip)

  
    long bytesSkipped = 0;
    for (; bytesSkipped < bytesToSkip; bytesSkipped++) {
      int c = this.read();
      if (c == -1) break;
    }
    return bytesSkipped;