home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / io / LineNumberInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.4 KB  |  91 lines

  1. package java.io;
  2.  
  3. /** @deprecated */
  4. public class LineNumberInputStream extends FilterInputStream {
  5.    int pushBack = -1;
  6.    int lineNumber;
  7.    int markLineNumber;
  8.  
  9.    public LineNumberInputStream(InputStream var1) {
  10.       super(var1);
  11.    }
  12.  
  13.    public int read() throws IOException {
  14.       int var1 = this.pushBack;
  15.       if (var1 != -1) {
  16.          this.pushBack = -1;
  17.       } else {
  18.          var1 = super.in.read();
  19.       }
  20.  
  21.       switch (var1) {
  22.          case 13:
  23.             this.pushBack = super.in.read();
  24.             if (this.pushBack == 10) {
  25.                this.pushBack = -1;
  26.             }
  27.          case 10:
  28.             ++this.lineNumber;
  29.             return 10;
  30.          default:
  31.             return var1;
  32.       }
  33.    }
  34.  
  35.    public int read(byte[] var1, int var2, int var3) throws IOException {
  36.       if (var3 <= 0) {
  37.          return 0;
  38.       } else {
  39.          int var4 = this.read();
  40.          if (var4 == -1) {
  41.             return -1;
  42.          } else {
  43.             var1[var2] = (byte)var4;
  44.             int var5 = 1;
  45.  
  46.             try {
  47.                for(; var5 < var3; ++var5) {
  48.                   var4 = this.read();
  49.                   if (var4 == -1) {
  50.                      break;
  51.                   }
  52.  
  53.                   if (var1 != null) {
  54.                      var1[var2 + var5] = (byte)var4;
  55.                   }
  56.                }
  57.             } catch (IOException var6) {
  58.             }
  59.  
  60.             return var5;
  61.          }
  62.       }
  63.    }
  64.  
  65.    public void setLineNumber(int var1) {
  66.       this.lineNumber = var1;
  67.    }
  68.  
  69.    public int getLineNumber() {
  70.       return this.lineNumber;
  71.    }
  72.  
  73.    public long skip(long var1) throws IOException {
  74.       return (long)((FilterInputStream)this).read(new byte[(int)var1]);
  75.    }
  76.  
  77.    public int available() throws IOException {
  78.       return this.pushBack == -1 ? super.available() : super.available() + 1;
  79.    }
  80.  
  81.    public void mark(int var1) {
  82.       this.markLineNumber = this.lineNumber;
  83.       super.in.mark(var1);
  84.    }
  85.  
  86.    public void reset() throws IOException {
  87.       this.lineNumber = this.markLineNumber;
  88.       super.in.reset();
  89.    }
  90. }
  91.