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

  1. package java.net;
  2.  
  3. import java.io.FileInputStream;
  4. import java.io.IOException;
  5.  
  6. class SocketInputStream extends FileInputStream {
  7.    private boolean eof;
  8.    private SocketImpl impl;
  9.    private byte[] temp = new byte[1];
  10.  
  11.    SocketInputStream(SocketImpl var1) throws IOException {
  12.       super(var1.getFileDescriptor());
  13.       this.impl = var1;
  14.    }
  15.  
  16.    private native int socketRead(byte[] var1, int var2, int var3) throws IOException;
  17.  
  18.    public int read(byte[] var1) throws IOException {
  19.       return this.read(var1, 0, var1.length);
  20.    }
  21.  
  22.    public int read(byte[] var1, int var2, int var3) throws IOException {
  23.       if (this.eof) {
  24.          return -1;
  25.       } else {
  26.          int var4 = this.socketRead(var1, var2, var3);
  27.          if (var4 <= 0) {
  28.             this.eof = true;
  29.             return -1;
  30.          } else {
  31.             return var4;
  32.          }
  33.       }
  34.    }
  35.  
  36.    public int read() throws IOException {
  37.       if (this.eof) {
  38.          return -1;
  39.       } else {
  40.          int var1 = this.read(this.temp, 0, 1);
  41.          return var1 <= 0 ? -1 : this.temp[0] & 255;
  42.       }
  43.    }
  44.  
  45.    public long skip(long var1) throws IOException {
  46.       if (var1 <= 0L) {
  47.          return 0L;
  48.       } else {
  49.          long var3 = var1;
  50.          int var5 = (int)Math.min(1024L, var1);
  51.  
  52.          int var7;
  53.          for(byte[] var6 = new byte[var5]; var3 > 0L; var3 -= (long)var7) {
  54.             var7 = this.read(var6, 0, (int)Math.min((long)var5, var3));
  55.             if (var7 < 0) {
  56.                break;
  57.             }
  58.          }
  59.  
  60.          return var1 - var3;
  61.       }
  62.    }
  63.  
  64.    public int available() throws IOException {
  65.       return this.impl.available();
  66.    }
  67.  
  68.    public void close() throws IOException {
  69.       this.impl.close();
  70.    }
  71.  
  72.    protected void finalize() {
  73.    }
  74. }
  75.