home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class RandomAccessFile implements DataOutput, DataInput {
- // $FF: renamed from: fd java.io.FileDescriptor
- private FileDescriptor field_0;
-
- public RandomAccessFile(String var1, String var2) throws IOException {
- boolean var3 = var2.equals("rw");
- if (!var3 && !var2.equals("r")) {
- throw new IllegalArgumentException("mode must be r or rw");
- } else {
- SecurityManager var4 = System.getSecurityManager();
- if (var4 != null) {
- var4.checkRead(var1);
- if (var3) {
- var4.checkWrite(var1);
- }
- }
-
- this.field_0 = new FileDescriptor();
- this.open(var1, var3);
- }
- }
-
- public RandomAccessFile(File var1, String var2) throws IOException {
- this(var1.getPath(), var2);
- }
-
- public final FileDescriptor getFD() throws IOException {
- if (this.field_0 != null) {
- return this.field_0;
- } else {
- throw new IOException();
- }
- }
-
- private native void open(String var1, boolean var2) throws IOException;
-
- public native int read() throws IOException;
-
- private native int readBytes(byte[] var1, int var2, int var3) throws IOException;
-
- public int read(byte[] var1, int var2, int var3) throws IOException {
- return this.readBytes(var1, var2, var3);
- }
-
- public int read(byte[] var1) throws IOException {
- return this.readBytes(var1, 0, var1.length);
- }
-
- public final void readFully(byte[] var1) throws IOException {
- this.readFully(var1, 0, var1.length);
- }
-
- public final void readFully(byte[] var1, int var2, int var3) throws IOException {
- int var5;
- for(int var4 = 0; var4 < var3; var4 += var5) {
- var5 = this.read(var1, var2 + var4, var3 - var4);
- if (var5 < 0) {
- throw new EOFException();
- }
- }
-
- }
-
- public int skipBytes(int var1) throws IOException {
- this.seek(this.getFilePointer() + (long)var1);
- return var1;
- }
-
- public native void write(int var1) throws IOException;
-
- private native void writeBytes(byte[] var1, int var2, int var3) throws IOException;
-
- public void write(byte[] var1) throws IOException {
- this.writeBytes(var1, 0, var1.length);
- }
-
- public void write(byte[] var1, int var2, int var3) throws IOException {
- this.writeBytes(var1, var2, var3);
- }
-
- public native long getFilePointer() throws IOException;
-
- public native void seek(long var1) throws IOException;
-
- public native long length() throws IOException;
-
- public native void close() throws IOException;
-
- public final boolean readBoolean() throws IOException {
- int var1 = this.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return var1 != 0;
- }
- }
-
- public final byte readByte() throws IOException {
- int var1 = this.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return (byte)var1;
- }
- }
-
- public final int readUnsignedByte() throws IOException {
- int var1 = this.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return var1;
- }
- }
-
- public final short readShort() throws IOException {
- int var1 = this.read();
- int var2 = this.read();
- if ((var1 | var2) < 0) {
- throw new EOFException();
- } else {
- return (short)((var1 << 8) + var2);
- }
- }
-
- public final int readUnsignedShort() throws IOException {
- int var1 = this.read();
- int var2 = this.read();
- if ((var1 | var2) < 0) {
- throw new EOFException();
- } else {
- return (var1 << 8) + var2;
- }
- }
-
- public final char readChar() throws IOException {
- int var1 = this.read();
- int var2 = this.read();
- if ((var1 | var2) < 0) {
- throw new EOFException();
- } else {
- return (char)((var1 << 8) + var2);
- }
- }
-
- public final int readInt() throws IOException {
- int var1 = this.read();
- int var2 = this.read();
- int var3 = this.read();
- int var4 = this.read();
- if ((var1 | var2 | var3 | var4) < 0) {
- throw new EOFException();
- } else {
- return (var1 << 24) + (var2 << 16) + (var3 << 8) + var4;
- }
- }
-
- public final long readLong() throws IOException {
- return ((long)this.readInt() << 32) + ((long)this.readInt() & 4294967295L);
- }
-
- public final float readFloat() throws IOException {
- return Float.intBitsToFloat(this.readInt());
- }
-
- public final double readDouble() throws IOException {
- return Double.longBitsToDouble(this.readLong());
- }
-
- public final String readLine() throws IOException {
- StringBuffer var1 = new StringBuffer();
-
- int var2;
- while((var2 = this.read()) != -1 && var2 != 10) {
- var1.append((char)var2);
- }
-
- return var2 == -1 && var1.length() == 0 ? null : var1.toString();
- }
-
- public final String readUTF() throws IOException {
- return DataInputStream.readUTF(this);
- }
-
- public final void writeBoolean(boolean var1) throws IOException {
- this.write(var1 ? 1 : 0);
- }
-
- public final void writeByte(int var1) throws IOException {
- this.write(var1);
- }
-
- public final void writeShort(int var1) throws IOException {
- this.write(var1 >>> 8 & 255);
- this.write(var1 & 255);
- }
-
- public final void writeChar(int var1) throws IOException {
- this.write(var1 >>> 8 & 255);
- this.write(var1 & 255);
- }
-
- public final void writeInt(int var1) throws IOException {
- this.write(var1 >>> 24 & 255);
- this.write(var1 >>> 16 & 255);
- this.write(var1 >>> 8 & 255);
- this.write(var1 & 255);
- }
-
- public final void writeLong(long var1) throws IOException {
- this.write((int)(var1 >>> 56) & 255);
- this.write((int)(var1 >>> 48) & 255);
- this.write((int)(var1 >>> 40) & 255);
- this.write((int)(var1 >>> 32) & 255);
- this.write((int)(var1 >>> 24) & 255);
- this.write((int)(var1 >>> 16) & 255);
- this.write((int)(var1 >>> 8) & 255);
- this.write((int)var1 & 255);
- }
-
- public final void writeFloat(float var1) throws IOException {
- this.writeInt(Float.floatToIntBits(var1));
- }
-
- public final void writeDouble(double var1) throws IOException {
- this.writeLong(Double.doubleToLongBits(var1));
- }
-
- public final void writeBytes(String var1) throws IOException {
- int var2 = var1.length();
- byte[] var3 = new byte[var2];
- var1.getBytes(0, var2, var3, 0);
- this.writeBytes(var3, 0, var2);
- }
-
- public final void writeChars(String var1) throws IOException {
- int var2 = var1.length();
- int var3 = 2 * var2;
- byte[] var4 = new byte[var3];
- char[] var5 = new char[var2];
- var1.getChars(0, var2, var5, 0);
- int var6 = 0;
-
- for(int var7 = 0; var6 < var2; ++var6) {
- var4[var7++] = (byte)(var5[var6] >>> 8);
- var4[var7++] = (byte)var5[var6];
- }
-
- this.writeBytes(var4, 0, var3);
- }
-
- public final void writeUTF(String var1) throws IOException {
- int var2 = var1.length();
- int var3 = 0;
-
- for(int var4 = 0; var4 < var2; ++var4) {
- char var5 = var1.charAt(var4);
- if (var5 >= 1 && var5 <= 127) {
- ++var3;
- } else if (var5 > 2047) {
- var3 += 3;
- } else {
- var3 += 2;
- }
- }
-
- if (var3 > 65535) {
- throw new UTFDataFormatException();
- } else {
- this.write(var3 >>> 8 & 255);
- this.write(var3 & 255);
-
- for(int var7 = 0; var7 < var2; ++var7) {
- char var6 = var1.charAt(var7);
- if (var6 >= 1 && var6 <= 127) {
- this.write(var6);
- } else if (var6 > 2047) {
- this.write(224 | var6 >> 12 & 15);
- this.write(128 | var6 >> 6 & 63);
- this.write(128 | var6 & 63);
- } else {
- this.write(192 | var6 >> 6 & 31);
- this.write(128 | var6 & 63);
- }
- }
-
- }
- }
- }
-