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 / io / RandomAccessFile.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  4.5 KB  |  299 lines

  1. package java.io;
  2.  
  3. public class RandomAccessFile implements DataOutput, DataInput {
  4.    // $FF: renamed from: fd java.io.FileDescriptor
  5.    private FileDescriptor field_0;
  6.  
  7.    public RandomAccessFile(String var1, String var2) throws FileNotFoundException {
  8.       boolean var3 = var2.equals("rw");
  9.       if (!var3 && !var2.equals("r")) {
  10.          throw new IllegalArgumentException("mode must be r or rw");
  11.       } else {
  12.          SecurityManager var4 = System.getSecurityManager();
  13.          if (var4 != null) {
  14.             var4.checkRead(var1);
  15.             if (var3) {
  16.                var4.checkWrite(var1);
  17.             }
  18.          }
  19.  
  20.          this.field_0 = new FileDescriptor();
  21.          this.open(var1, var3);
  22.       }
  23.    }
  24.  
  25.    public RandomAccessFile(File var1, String var2) throws FileNotFoundException {
  26.       this(var1.getPath(), var2);
  27.    }
  28.  
  29.    public final FileDescriptor getFD() throws IOException {
  30.       if (this.field_0 != null) {
  31.          return this.field_0;
  32.       } else {
  33.          throw new IOException();
  34.       }
  35.    }
  36.  
  37.    private native void open(String var1, boolean var2) throws FileNotFoundException;
  38.  
  39.    public native int read() throws IOException;
  40.  
  41.    private native int readBytes(byte[] var1, int var2, int var3) throws IOException;
  42.  
  43.    public int read(byte[] var1, int var2, int var3) throws IOException {
  44.       return this.readBytes(var1, var2, var3);
  45.    }
  46.  
  47.    public int read(byte[] var1) throws IOException {
  48.       return this.readBytes(var1, 0, var1.length);
  49.    }
  50.  
  51.    public final void readFully(byte[] var1) throws IOException {
  52.       this.readFully(var1, 0, var1.length);
  53.    }
  54.  
  55.    public final void readFully(byte[] var1, int var2, int var3) throws IOException {
  56.       int var4 = 0;
  57.  
  58.       do {
  59.          int var5 = this.read(var1, var2 + var4, var3 - var4);
  60.          if (var5 < 0) {
  61.             throw new EOFException();
  62.          }
  63.  
  64.          var4 += var5;
  65.       } while(var4 < var3);
  66.  
  67.    }
  68.  
  69.    public int skipBytes(int var1) throws IOException {
  70.       if (var1 <= 0) {
  71.          return 0;
  72.       } else {
  73.          long var2 = this.getFilePointer();
  74.          long var4 = this.length();
  75.          long var6 = var2 + (long)var1;
  76.          if (var6 > var4) {
  77.             var6 = var4;
  78.          }
  79.  
  80.          this.seek(var6);
  81.          return (int)(var6 - var2);
  82.       }
  83.    }
  84.  
  85.    public native void write(int var1) throws IOException;
  86.  
  87.    private native void writeBytes(byte[] var1, int var2, int var3) throws IOException;
  88.  
  89.    public void write(byte[] var1) throws IOException {
  90.       this.writeBytes(var1, 0, var1.length);
  91.    }
  92.  
  93.    public void write(byte[] var1, int var2, int var3) throws IOException {
  94.       this.writeBytes(var1, var2, var3);
  95.    }
  96.  
  97.    public native long getFilePointer() throws IOException;
  98.  
  99.    public native void seek(long var1) throws IOException;
  100.  
  101.    public native long length() throws IOException;
  102.  
  103.    public native void setLength(long var1) throws IOException;
  104.  
  105.    public native void close() throws IOException;
  106.  
  107.    public final boolean readBoolean() throws IOException {
  108.       int var1 = this.read();
  109.       if (var1 < 0) {
  110.          throw new EOFException();
  111.       } else {
  112.          return var1 != 0;
  113.       }
  114.    }
  115.  
  116.    public final byte readByte() throws IOException {
  117.       int var1 = this.read();
  118.       if (var1 < 0) {
  119.          throw new EOFException();
  120.       } else {
  121.          return (byte)var1;
  122.       }
  123.    }
  124.  
  125.    public final int readUnsignedByte() throws IOException {
  126.       int var1 = this.read();
  127.       if (var1 < 0) {
  128.          throw new EOFException();
  129.       } else {
  130.          return var1;
  131.       }
  132.    }
  133.  
  134.    public final short readShort() throws IOException {
  135.       int var1 = this.read();
  136.       int var2 = this.read();
  137.       if ((var1 | var2) < 0) {
  138.          throw new EOFException();
  139.       } else {
  140.          return (short)((var1 << 8) + (var2 << 0));
  141.       }
  142.    }
  143.  
  144.    public final int readUnsignedShort() throws IOException {
  145.       int var1 = this.read();
  146.       int var2 = this.read();
  147.       if ((var1 | var2) < 0) {
  148.          throw new EOFException();
  149.       } else {
  150.          return (var1 << 8) + (var2 << 0);
  151.       }
  152.    }
  153.  
  154.    public final char readChar() throws IOException {
  155.       int var1 = this.read();
  156.       int var2 = this.read();
  157.       if ((var1 | var2) < 0) {
  158.          throw new EOFException();
  159.       } else {
  160.          return (char)((var1 << 8) + (var2 << 0));
  161.       }
  162.    }
  163.  
  164.    public final int readInt() throws IOException {
  165.       int var1 = this.read();
  166.       int var2 = this.read();
  167.       int var3 = this.read();
  168.       int var4 = this.read();
  169.       if ((var1 | var2 | var3 | var4) < 0) {
  170.          throw new EOFException();
  171.       } else {
  172.          return (var1 << 24) + (var2 << 16) + (var3 << 8) + (var4 << 0);
  173.       }
  174.    }
  175.  
  176.    public final long readLong() throws IOException {
  177.       return ((long)this.readInt() << 32) + ((long)this.readInt() & 4294967295L);
  178.    }
  179.  
  180.    public final float readFloat() throws IOException {
  181.       return Float.intBitsToFloat(this.readInt());
  182.    }
  183.  
  184.    public final double readDouble() throws IOException {
  185.       return Double.longBitsToDouble(this.readLong());
  186.    }
  187.  
  188.    public final String readLine() throws IOException {
  189.       StringBuffer var1 = new StringBuffer();
  190.       int var2 = -1;
  191.       boolean var3 = false;
  192.  
  193.       while(!var3) {
  194.          switch (var2 = this.read()) {
  195.             case -1:
  196.             case 10:
  197.                var3 = true;
  198.                break;
  199.             case 13:
  200.                var3 = true;
  201.                long var4 = this.getFilePointer();
  202.                if (this.read() != 10) {
  203.                   this.seek(var4);
  204.                }
  205.                break;
  206.             default:
  207.                var1.append((char)var2);
  208.          }
  209.       }
  210.  
  211.       if (var2 == -1 && var1.length() == 0) {
  212.          return null;
  213.       } else {
  214.          return var1.toString();
  215.       }
  216.    }
  217.  
  218.    public final String readUTF() throws IOException {
  219.       return DataInputStream.readUTF(this);
  220.    }
  221.  
  222.    public final void writeBoolean(boolean var1) throws IOException {
  223.       this.write(var1 ? 1 : 0);
  224.    }
  225.  
  226.    public final void writeByte(int var1) throws IOException {
  227.       this.write(var1);
  228.    }
  229.  
  230.    public final void writeShort(int var1) throws IOException {
  231.       this.write(var1 >>> 8 & 255);
  232.       this.write(var1 >>> 0 & 255);
  233.    }
  234.  
  235.    public final void writeChar(int var1) throws IOException {
  236.       this.write(var1 >>> 8 & 255);
  237.       this.write(var1 >>> 0 & 255);
  238.    }
  239.  
  240.    public final void writeInt(int var1) throws IOException {
  241.       this.write(var1 >>> 24 & 255);
  242.       this.write(var1 >>> 16 & 255);
  243.       this.write(var1 >>> 8 & 255);
  244.       this.write(var1 >>> 0 & 255);
  245.    }
  246.  
  247.    public final void writeLong(long var1) throws IOException {
  248.       this.write((int)(var1 >>> 56) & 255);
  249.       this.write((int)(var1 >>> 48) & 255);
  250.       this.write((int)(var1 >>> 40) & 255);
  251.       this.write((int)(var1 >>> 32) & 255);
  252.       this.write((int)(var1 >>> 24) & 255);
  253.       this.write((int)(var1 >>> 16) & 255);
  254.       this.write((int)(var1 >>> 8) & 255);
  255.       this.write((int)(var1 >>> 0) & 255);
  256.    }
  257.  
  258.    public final void writeFloat(float var1) throws IOException {
  259.       this.writeInt(Float.floatToIntBits(var1));
  260.    }
  261.  
  262.    public final void writeDouble(double var1) throws IOException {
  263.       this.writeLong(Double.doubleToLongBits(var1));
  264.    }
  265.  
  266.    public final void writeBytes(String var1) throws IOException {
  267.       int var2 = var1.length();
  268.       byte[] var3 = new byte[var2];
  269.       var1.getBytes(0, var2, var3, 0);
  270.       this.writeBytes(var3, 0, var2);
  271.    }
  272.  
  273.    public final void writeChars(String var1) throws IOException {
  274.       int var2 = var1.length();
  275.       int var3 = 2 * var2;
  276.       byte[] var4 = new byte[var3];
  277.       char[] var5 = new char[var2];
  278.       var1.getChars(0, var2, var5, 0);
  279.       int var6 = 0;
  280.  
  281.       for(int var7 = 0; var6 < var2; ++var6) {
  282.          var4[var7++] = (byte)(var5[var6] >>> 8);
  283.          var4[var7++] = (byte)(var5[var6] >>> 0);
  284.       }
  285.  
  286.       this.writeBytes(var4, 0, var3);
  287.    }
  288.  
  289.    public final void writeUTF(String var1) throws IOException {
  290.       DataOutputStream.writeUTF(var1, this);
  291.    }
  292.  
  293.    private static native void initIDs();
  294.  
  295.    static {
  296.       initIDs();
  297.    }
  298. }
  299.