RandomAccessFile Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.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
- 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
| Name | Description |
|---|---|
| RandomAccessFile(File, String) |
Creates a random access file stream to read from, and optionally to
write to, the file specified by the |
| 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
| Name | Description |
|---|---|
| Channel |
Returns the unique |
| Class |
Returns the runtime class of this |
| 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 |
Gets the identity hash code assigned to this Java peer by the interop runtime. (Inherited from Object) |
| JniManagedPeerState |
Gets the state flags last assigned by the runtime. (Inherited from JavaObject) |
| JniPeerMembers |
Gets the JNI metadata used to access members of this Java binding. |
| PeerReference |
Gets the JNI object reference for this Java peer. (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
| Name | Description |
|---|---|
| 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. |
| Construct(JniObjectReference, JniObjectReferenceOptions) |
Delegates construction of this peer to the runtime's value manager. (Inherited from JavaObject) |
| Dispose() |
Releases the resources held by this Java peer. (Inherited from Object) |
| Dispose(Boolean) |
Releases the resources held by this Java peer. (Inherited from Object) |
| DisposeUnlessReferenced() |
Asks the value manager to dispose this peer unless its mapping retains this same managed instance. (Inherited from JavaObject) |
| Equals(Object) |
Tests whether another managed peer refers to the same Java object. (Inherited from JavaObject) |
| 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() |
Obsolete.
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 |
| Read(Byte[]) |
Reads up to |
| ReadAsync() |
Reads one byte from the file in a task. |
| ReadAsync(Byte[], Int32, Int32) |
Reads file bytes into a buffer range in a task. |
| ReadAsync(Byte[]) |
Reads file bytes into a buffer in a task. |
| ReadBoolean() |
Reads a |
| ReadBooleanAsync() |
Reads a Boolean value from the file in a task. |
| ReadByte() |
Reads a signed eight-bit value from this file. |
| ReadByteAsync() |
Reads a signed byte from the file in a task. |
| ReadChar() |
Reads a character from this file. |
| ReadCharAsync() |
Reads a 16-bit character from the file in a task. |
| ReadDouble() |
Reads a |
| ReadDoubleAsync() |
Reads a double-precision value from the file in a task. |
| ReadFloat() |
Reads a |
| ReadFloatAsync() |
Reads a single-precision value from the file in a task. |
| ReadFully(Byte[], Int32, Int32) |
Reads exactly |
| ReadFully(Byte[]) |
Reads |
| ReadFullyAsync(Byte[], Int32, Int32) |
Fills a buffer range from the file in a task. |
| ReadFullyAsync(Byte[]) |
Fills the byte array from the file in a task. |
| ReadInt() |
Reads a signed 32-bit integer from this file. |
| ReadIntAsync() |
Reads a signed 32-bit integer from the file in a task. |
| ReadLine() |
Reads the next line of text from this file. |
| ReadLineAsync() |
Reads a byte-based text line from the file in a task. |
| ReadLong() |
Reads a signed 64-bit integer from this file. |
| ReadLongAsync() |
Reads a signed 64-bit integer from the file in a task. |
| ReadShort() |
Reads a signed 16-bit number from this file. |
| ReadShortAsync() |
Reads a signed 16-bit integer from the file in a task. |
| ReadUnsignedByte() |
Reads an unsigned eight-bit number from this file. |
| ReadUnsignedByteAsync() |
Reads an unsigned byte from the file in a task. |
| ReadUnsignedShort() |
Reads an unsigned 16-bit number from this file. |
| ReadUnsignedShortAsync() |
Reads an unsigned 16-bit integer from the file in a task. |
| ReadUTF() |
Reads in a string from this file. |
| ReadUTFAsync() |
Reads length-prefixed modified UTF-8 text from the file in a task. |
| 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. |
| SetPeerReference(JniObjectReference, JniObjectReferenceOptions) |
Stores a reference value in the control block without creating a JNI reference copy. (Inherited from JavaObject) |
| SkipBytes(Int32) |
Attempts to skip over |
| SkipBytesAsync(Int32) |
Runs a byte-skip operation on the file in a task. |
| ToArray<T>() |
Creates a managed array from this Java array wrapper. (Inherited from Object) |
| ToString() |
Returns a string representation of the object. (Inherited from Object) |
| UnregisterFromRuntime() |
Unregisters this Java peer from the interop runtime. (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 |
| Write(Byte[]) |
Writes |
| Write(Int32) |
Writes the specified byte to this file. |
| WriteAsync(Byte[], Int32, Int32) |
Writes a byte-array range to the file in a task. |
| WriteAsync(Byte[]) |
Writes the byte array to the file in a task. |
| WriteAsync(Int32) |
Writes one byte to the file in a task. |
| WriteBoolean(Boolean) |
Writes a |
| WriteBooleanAsync(Boolean) |
Writes a Boolean value to the file as one byte in a task. |
| WriteByte(Int32) |
Writes a |
| WriteByteAsync(Int32) |
Writes an 8-bit value to the file in a task. |
| WriteBytes(String) |
Writes the string to the file as a sequence of bytes. |
| WriteBytesAsync(String) |
Writes one file byte per string character in a task. |
| WriteChar(Int32) |
Writes a |
| WriteCharAsync(Int32) |
Writes a 16-bit character to the file with the high byte first in a task. |
| WriteChars(String) |
Writes a string to the file as a sequence of characters. |
| WriteCharsAsync(String) |
Writes two file bytes per string character in a task. |
| WriteDouble(Double) |
Converts the double argument to a |
| WriteDoubleAsync(Double) |
Writes a double-precision value to the file in a task. |
| WriteFloat(Single) |
Converts the float argument to an |
| WriteFloatAsync(Single) |
Writes a single-precision value to the file in a task. |
| WriteInt(Int32) |
Writes an |
| WriteIntAsync(Int32) |
Writes a 32-bit integer to the file with the high byte first in a task. |
| WriteLong(Int64) |
Writes a |
| WriteLongAsync(Int64) |
Writes a 64-bit integer to the file with the high byte first in a task. |
| WriteShort(Int32) |
Writes a |
| WriteShortAsync(Int32) |
Writes a 16-bit integer to the file with the high byte first in a task. |
| WriteUTF(String) |
Writes a string to the file using modified UTF-8 encoding in a machine-independent manner. |
| WriteUTFAsync(String) |
Writes length-prefixed modified UTF-8 text to the file in a task. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IJavaPeerable.Disposed() |
Marks this peer as disposed and calls |
| IJavaPeerable.Finalized() |
Marks this peer as disposed and calls |
| IJavaPeerable.JniObjectReferenceControlBlock |
Gets the native control-block pointer used by this peer. (Inherited from JavaObject) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
Stores the identity hash code supplied by the runtime. (Inherited from JavaObject) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
Replaces the stored managed peer state flags. (Inherited from JavaObject) |
| IJavaPeerable.SetPeerReference(JniObjectReference) |
Updates the peer reference and releases a disposed peer's control block when the reference is invalid. (Inherited from JavaObject) |
| IJavaPeerable.UnregisterFromRuntime() |
Removes this instance from the runtime's Java object lookup. |
Extension Methods
| Name | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
| JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
| JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
| JavaCast<TResult>(IJavaObject) |
Reuses a compatible managed peer or obtains a wrapper of the requested type. |
| ReadBooleanAsync(IDataInput) |
Reads a Boolean value in a task. |
| ReadByteAsync(IDataInput) |
Reads a signed byte in a task. |
| ReadCharAsync(IDataInput) |
Reads a 16-bit character in a task. |
| ReadDoubleAsync(IDataInput) |
Reads a double-precision value in a task. |
| ReadFloatAsync(IDataInput) |
Reads a single-precision value in a task. |
| ReadFullyAsync(IDataInput, Byte[], Int32, Int32) |
Fills a buffer range from the input in a task. |
| ReadFullyAsync(IDataInput, Byte[]) |
Fills the byte array from the input in a task. |
| ReadIntAsync(IDataInput) |
Reads a signed 32-bit integer in a task. |
| ReadLineAsync(IDataInput) |
Reads a byte-based text line in a task. |
| ReadLongAsync(IDataInput) |
Reads a signed 64-bit integer in a task. |
| ReadShortAsync(IDataInput) |
Reads a signed 16-bit integer in a task. |
| ReadUnsignedByteAsync(IDataInput) |
Reads an unsigned byte in a task. |
| ReadUnsignedShortAsync(IDataInput) |
Reads an unsigned 16-bit integer in a task. |
| ReadUTFAsync(IDataInput) |
Reads length-prefixed modified UTF-8 text in a task. |
| SkipBytesAsync(IDataInput, Int32) |
Skips input bytes in a task. |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |
| WriteAsync(IDataOutput, Byte[], Int32, Int32) |
Writes a byte-array range to the output in a task. |
| WriteAsync(IDataOutput, Byte[]) |
Writes the byte array to the output in a task. |
| WriteAsync(IDataOutput, Int32) |
Writes one byte to the output in a task. |
| WriteBooleanAsync(IDataOutput, Boolean) |
Writes a Boolean value as one byte in a task. |
| WriteByteAsync(IDataOutput, Int32) |
Writes an 8-bit value in a task. |
| WriteBytesAsync(IDataOutput, String) |
Writes one byte per string character in a task. |
| WriteCharAsync(IDataOutput, Int32) |
Writes a 16-bit character with the high byte first in a task. |
| WriteCharsAsync(IDataOutput, String) |
Writes two bytes per string character in a task. |
| WriteDoubleAsync(IDataOutput, Double) |
Writes a double-precision value in a task. |
| WriteFloatAsync(IDataOutput, Single) |
Writes a single-precision value in a task. |
| WriteIntAsync(IDataOutput, Int32) |
Writes a 32-bit integer with the high byte first in a task. |
| WriteLongAsync(IDataOutput, Int64) |
Writes a 64-bit integer with the high byte first in a task. |
| WriteShortAsync(IDataOutput, Int32) |
Writes a 16-bit integer with the high byte first in a task. |
| WriteUTFAsync(IDataOutput, String) |
Writes length-prefixed modified UTF-8 text in a task. |