FileDocCategorySizeDatePackage
DumpFilter.javaAPI DocExample2450Tue May 04 14:30:06 BST 1999com.macfaq.io

DumpFilter

public abstract class DumpFilter extends FilterInputStream

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

  
     
    super(in);
  
Methods Summary
public intavailable()

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

public synchronized 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 e) {
        result = -1;
      }
    }  // end else
    
    return result;
    
  
public intread(byte[] data, int offset, int length)

  
    if (data == null) {
      throw new NullPointerException();
    } 
    else if ((offset < 0) || (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 e) {
      // return what's already in the data array
    }
    
    return bytesRead;   
    
  
public synchronized 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;