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

  1. package sun.net.nntp;
  2.  
  3. import java.io.FilterInputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6.  
  7. class NntpInputStream extends FilterInputStream {
  8.    int column;
  9.    boolean eofOccurred = false;
  10.  
  11.    public NntpInputStream(InputStream var1) {
  12.       super(var1);
  13.    }
  14.  
  15.    int eof() {
  16.       this.eofOccurred = true;
  17.       return -1;
  18.    }
  19.  
  20.    public int read() throws IOException {
  21.       if (this.eofOccurred) {
  22.          return -1;
  23.       } else {
  24.          int var1 = super.read();
  25.          if (var1 == 46 && this.column == 0) {
  26.             var1 = super.read();
  27.             if (var1 == 10) {
  28.                return this.eof();
  29.             }
  30.  
  31.             if (var1 != 46) {
  32.                throw new NntpProtocolException("Expecting '.' - got " + var1);
  33.             }
  34.          }
  35.  
  36.          if (var1 == 10) {
  37.             this.column = 0;
  38.          } else {
  39.             ++this.column;
  40.          }
  41.  
  42.          return var1;
  43.       }
  44.    }
  45.  
  46.    public int read(byte[] var1) throws IOException {
  47.       return this.read(var1, 0, var1.length);
  48.    }
  49.  
  50.    public int read(byte[] var1, int var2, int var3) throws IOException {
  51.       int var5 = var2;
  52.  
  53.       while(true) {
  54.          --var3;
  55.          if (var3 < 0) {
  56.             break;
  57.          }
  58.  
  59.          int var4 = this.read();
  60.          if (var4 == -1) {
  61.             break;
  62.          }
  63.  
  64.          var1[var2++] = (byte)var4;
  65.       }
  66.  
  67.       return var2 > var5 ? var2 - var5 : -1;
  68.    }
  69.  
  70.    public void close() {
  71.    }
  72. }
  73.