home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / net / SocketInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.2 KB  |  88 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;
  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 if (var3 == 0) {
  26.          return 0;
  27.       } else {
  28.          int var4 = this.socketRead(var1, var2, var3);
  29.          if (var4 <= 0) {
  30.             this.eof = true;
  31.             return -1;
  32.          } else {
  33.             return var4;
  34.          }
  35.       }
  36.    }
  37.  
  38.    public int read() throws IOException {
  39.       if (this.eof) {
  40.          return -1;
  41.       } else {
  42.          this.temp = new byte[1];
  43.          int var1 = this.read(this.temp, 0, 1);
  44.          return var1 <= 0 ? -1 : this.temp[0] & 255;
  45.       }
  46.    }
  47.  
  48.    public long skip(long var1) throws IOException {
  49.       if (var1 <= 0L) {
  50.          return 0L;
  51.       } else {
  52.          long var3 = var1;
  53.          int var5 = (int)Math.min(1024L, var1);
  54.  
  55.          int var7;
  56.          for(byte[] var6 = new byte[var5]; var3 > 0L; var3 -= (long)var7) {
  57.             var7 = this.read(var6, 0, (int)Math.min((long)var5, var3));
  58.             if (var7 < 0) {
  59.                break;
  60.             }
  61.          }
  62.  
  63.          return var1 - var3;
  64.       }
  65.    }
  66.  
  67.    public int available() throws IOException {
  68.       return this.impl.available();
  69.    }
  70.  
  71.    public void close() throws IOException {
  72.       this.impl.close();
  73.    }
  74.  
  75.    void setEOF(boolean var1) {
  76.       this.eof = var1;
  77.    }
  78.  
  79.    protected void finalize() {
  80.    }
  81.  
  82.    private static native void init();
  83.  
  84.    static {
  85.       init();
  86.    }
  87. }
  88.