Sdílet prostřednictvím


RandomAccessFile Class

Definition

Instances of this class support both reading and writing to a random access file.

[Android.Runtime.Register("java/io/RandomAccessFile", DoNotGenerateAcw=true)]
public class RandomAccessFile : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ICloseable, Java.IO.IDataInput, Java.IO.IDataOutput
[<Android.Runtime.Register("java/io/RandomAccessFile", DoNotGenerateAcw=true)>]
type RandomAccessFile = class
    inherit Object
    interface ICloseable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IDataInput
    interface IDataOutput
Inheritance
RandomAccessFile
Attributes
Implements

Remarks

Instances of this class support both reading and writing to a random access file. A random access file behaves like a large array of bytes stored in the file system. There is a kind of cursor, or index into the implied array, called the <em>file pointer</em>; input operations read bytes starting at the file pointer and advance the file pointer past the bytes read. If the random access file is created in read/write mode, then output operations are also available; output operations write bytes starting at the file pointer and advance the file pointer past the bytes written. Output operations that write past the current end of the implied array cause the array to be extended. The file pointer can be read by the getFilePointer method and set by the seek method.

It is generally true of all the reading routines in this class that if end-of-file is reached before the desired number of bytes has been read, an EOFException (which is a kind of IOException) is thrown. If any byte cannot be read for any reason other than end-of-file, an IOException other than EOFException is thrown. In particular, an IOException may be thrown if the stream has been closed.

Added in JDK1.0.

Java documentation for java.io.RandomAccessFile.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

RandomAccessFile(File, String)

Creates a random access file stream to read from, and optionally to write to, the file specified by the File argument.

RandomAccessFile(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

RandomAccessFile(String, String)

Creates a random access file stream to read from, and optionally to write to, a file with the specified name.

Properties

Channel

Returns the unique java.nio.channels.FileChannel FileChannel object associated with this file.

Class

Returns the runtime class of this Object.

(Inherited from Object)
FD

Returns the opaque file descriptor object associated with this stream.

FilePointer

Returns the current offset in this file.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Close()

Closes this random access file stream and releases any system resources associated with the stream.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Length()

Returns the length of this file.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Read()

Reads a byte of data from this file.

Read(Byte[], Int32, Int32)

Reads up to len bytes of data from this file into an array of bytes.

Read(Byte[])

Reads up to b.length bytes of data from this file into an array of bytes.

ReadAsync()
ReadAsync(Byte[], Int32, Int32)
ReadAsync(Byte[])
ReadBoolean()

Reads a boolean from this file.

ReadBooleanAsync()
ReadByte()

Reads a signed eight-bit value from this file.

ReadByteAsync()
ReadChar()

Reads a character from this file.

ReadCharAsync()
ReadDouble()

Reads a double from this file.

ReadDoubleAsync()
ReadFloat()

Reads a float from this file.

ReadFloatAsync()
ReadFully(Byte[], Int32, Int32)

Reads exactly len bytes from this file into the byte array, starting at the current file pointer.

ReadFully(Byte[])

Reads b.length bytes from this file into the byte array, starting at the current file pointer.

ReadFullyAsync(Byte[], Int32, Int32)
ReadFullyAsync(Byte[])
ReadInt()

Reads a signed 32-bit integer from this file.

ReadIntAsync()
ReadLine()

Reads the next line of text from this file.

ReadLineAsync()
ReadLong()

Reads a signed 64-bit integer from this file.

ReadLongAsync()
ReadShort()

Reads a signed 16-bit number from this file.

ReadShortAsync()
ReadUnsignedByte()

Reads an unsigned eight-bit number from this file.

ReadUnsignedByteAsync()
ReadUnsignedShort()

Reads an unsigned 16-bit number from this file.

ReadUnsignedShortAsync()
ReadUTF()

Reads in a string from this file.

ReadUTFAsync()
Seek(Int64)

Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLength(Int64)

Sets the length of this file.

SkipBytes(Int32)

Attempts to skip over n bytes of input discarding the skipped bytes.

SkipBytesAsync(Int32)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Write(Byte[], Int32, Int32)

Writes len bytes from the specified byte array starting at offset off to this file.

Write(Byte[])

Writes b.length bytes from the specified byte array to this file, starting at the current file pointer.

Write(Int32)

Writes the specified byte to this file.

WriteAsync(Byte[], Int32, Int32)
WriteAsync(Byte[])
WriteAsync(Int32)
WriteBoolean(Boolean)

Writes a boolean to the file as a one-byte value.

WriteBooleanAsync(Boolean)
WriteByte(Int32)

Writes a byte to the file as a one-byte value.

WriteByteAsync(Int32)
WriteBytes(String)

Writes the string to the file as a sequence of bytes.

WriteBytesAsync(String)
WriteChar(Int32)

Writes a char to the file as a two-byte value, high byte first.

WriteCharAsync(Int32)
WriteChars(String)

Writes a string to the file as a sequence of characters.

WriteCharsAsync(String)
WriteDouble(Double)

Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the file as an eight-byte quantity, high byte first.

WriteDoubleAsync(Double)
WriteFloat(Single)

Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the file as a four-byte quantity, high byte first.

WriteFloatAsync(Single)
WriteInt(Int32)

Writes an int to the file as four bytes, high byte first.

WriteIntAsync(Int32)
WriteLong(Int64)

Writes a long to the file as eight bytes, high byte first.

WriteLongAsync(Int64)
WriteShort(Int32)

Writes a short to the file as two bytes, high byte first.

WriteShortAsync(Int32)
WriteUTF(String)

Writes a string to the file using modified UTF-8 encoding in a machine-independent manner.

WriteUTFAsync(String)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
ReadBooleanAsync(IDataInput)
ReadByteAsync(IDataInput)
ReadCharAsync(IDataInput)
ReadDoubleAsync(IDataInput)
ReadFloatAsync(IDataInput)
ReadFullyAsync(IDataInput, Byte[], Int32, Int32)
ReadFullyAsync(IDataInput, Byte[])
ReadIntAsync(IDataInput)
ReadLineAsync(IDataInput)
ReadLongAsync(IDataInput)
ReadShortAsync(IDataInput)
ReadUnsignedByteAsync(IDataInput)
ReadUnsignedShortAsync(IDataInput)
ReadUTFAsync(IDataInput)
SkipBytesAsync(IDataInput, Int32)
WriteAsync(IDataOutput, Byte[], Int32, Int32)
WriteAsync(IDataOutput, Byte[])
WriteAsync(IDataOutput, Int32)
WriteBooleanAsync(IDataOutput, Boolean)
WriteByteAsync(IDataOutput, Int32)
WriteBytesAsync(IDataOutput, String)
WriteCharAsync(IDataOutput, Int32)
WriteCharsAsync(IDataOutput, String)
WriteDoubleAsync(IDataOutput, Double)
WriteFloatAsync(IDataOutput, Single)
WriteIntAsync(IDataOutput, Int32)
WriteLongAsync(IDataOutput, Int64)
WriteShortAsync(IDataOutput, Int32)
WriteUTFAsync(IDataOutput, String)

Applies to