- Java.io - Writer
- Java.io - StringWriter
- Java.io - StringReader
- Java.io - StringBufferInputStream
- Java.io - StreamTokenizer
- Java.io - SerializablePermission
- Java.io - SequenceInputStream
- Java.io - Reader
- Java.io - RandomAccessFile
- Java.io - PushbackReader
- Java.io - PushbackInputStream
- Java.io - PrintWriter
- Java.io - PrintStream
- Java.io - PipedWriter
- Java.io - PipedReader
- Java.io - PipedOutputStream
- Java.io - PipedInputStream
- Java.io - OutputStreamWriter
- Java.io - OutputStream
- Java.io - ObjectStreamField
- Java.io - ObjectStreamClass
- io - ObjectOutputStream.PutField
- Java.io - ObjectOutputStream
- Java.io - ObjectInputStream.GetField
- Java.io - ObjectInputStream
- Java.io - LineNumberReader
- Java.io - LineNumberInputStream
- Java.io - InputStreamReader
- Java.io - InputStream
- Java.io - FilterWriter
- Java.io - FilterReader
- Java.io - FilterOutputStream
- Java.io - FilterInputStream
- Java.io - FileWriter
- Java.io - FileReader
- Java.io - FilePermission
- Java.io - FileOutputStream
- Java.io - FileInputStream
- Java.io - FileDescriptor
- Java.io - File
- Java.io - DataOutputStream
- Java.io - DataInputStream
- Java.io - Console
- Java.io - CharArrayWriter
- Java.io - CharArrayReader
- Java.io - ByteArrayOutputStream
- Java.io - ByteArrayInputStream
- Java.io - BufferedWriter
- Java.io - BufferedReader
- Java.io - BufferedOutputStream
- Java.io - BufferedInputStream
- Java.io - Home
Java.io package extras
Java.io package Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.io.RandomAccessFile Class
Introduction
The Java.io.RandomAccessFile class file behaves pke a large array of bytes stored in the file system.Instances of this class support both reading and writing to a random access file.
Class declaration
Following is the declaration for Java.io.RandomAccessFile class −
pubpc class RandomAccessFile extends Object implements DataOutput, DataInput, Closeable
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 | RandomAccessFile(File file, String mode) This creates a random access file stream to read from, and optionally to write to, the file specified by the File argument. |
2 | RandomAccessFile(File file, String mode) This creates a random access file stream to read from, and optionally to write to, a file with the specified name. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method Closes this random access file stream and releases any system resources associated with the stream. |
2 | This method returns the unique FileChannel object associated with this file. |
3 | This method returns the opaque file descriptor object associated with this stream. |
4 | This method returns the current offset in this file. |
5 | This method returns the length of this file. |
6 | This method reads a byte of data from this file. |
7 | This method reads up to b.length bytes of data from this file into an array of bytes. |
8 | This method reads up to len bytes of data from this file into an array of bytes. |
9 | This method reads a boolean from this file. |
10 | This method reads a signed eight-bit value from this file. |
11 | This method reads a character from this file. |
12 | This method reads a double from this file. |
13 | This method reads a float from this file. |
14 | This method reads b.length bytes from this file into the byte array, starting at the current file pointer. |
15 | This method reads exactly len bytes from this file into the byte array, starting at the current file pointer. |
16 | This method reads a signed 32-bit integer from this file. |
17 | This method reads the next pne of text from this file. |
18 | This method reads a signed 64-bit integer from this file. |
19 | This method reads a signed 16-bit number from this file. |
20 | This method reads an unsigned eight-bit number from this file. |
21 | This method reads an unsigned 16-bit number from this file. |
22 | This method reads in a string from this file. |
23 | This method sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. |
24 | This method sets the length of this file. |
25 | This method attempts to skip over n bytes of input discarding the skipped bytes. |
26 | This method writes b.length bytes from the specified byte array to this file, starting at the current file pointer. |
27 | This method writes len bytes from the specified byte array starting at offset off to this file. |
28 | This method writes the specified byte to this file. |
29 | This method writes a boolean to the file as a one-byte value. |
30 | This method writes a byte to the file as a one-byte value. |
31 | This method writes the string to the file as a sequence of bytes. |
32 | This method writes a char to the file as a two-byte value, high byte first. |
33 | This method writes a string to the file as a sequence of characters. |
34 | This method 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. |
35 | This method 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. |
36 | This method writes an int to the file as four bytes, high byte first. |
37 | This method writes a long to the file as eight bytes, high byte first. |
38 | This method writes a short to the file as two bytes, high byte first. |
39 | This method writes a string to the file using modified UTF-8 encoding in a machine-independent manner. |
Methods inherited
This class inherits methods from the following classes −
Java.io.Object