FileDocCategorySizeDatePackage
DecimalFilter.javaAPI DocExample1583Sun Mar 28 19:06:12 BST 1999com.macfaq.io

DecimalFilter

public class DecimalFilter extends DumpFilter

Fields Summary
protected int
numRead
protected int
breakAfter
protected int
ratio
Constructors Summary
public DecimalFilter(InputStream in)

 // number of bytes of output per byte of input

     
    super(in);
  
Methods Summary
public intavailable()

    return (buf.length - index) + ratio * in.available();
  
protected voidfill()

  
    buf = new int[ratio];
    int datum = in.read();
    this.numRead++;    
    if (datum == -1) {
      // let read() handle end of stream
      throw new EOFException();
    }

    String dec = Integer.toString(datum);
    if (datum < 10) { // add two leading zeroes
      dec = "00" + dec;
    }
    else if (datum < 100) { // add leading zero
      dec = '0" + dec;
    }
    for (int i = 0; i < dec.length(); i++) {
      buf[i] = dec.charAt(i);
    }
    if (numRead < breakAfter) {
      buf[buf.length - 1] = ' ";
    }
    else {
      buf[buf.length - 1] = '\n";
      numRead = 0;
    }