An exception will be thrown if a program attempts to read beyond the end of a file.
Methods Modifier and TypeMethod and Description Closes this random access file stream and releases any system resources associated with the stream. Show
FileChannel
getChannel() Returns the unique FileDescriptor
getFD() Returns the opaque file descriptor object associated with this stream. long
getFilePointer() Returns the current offset in this file. long
length() Returns the length of this file. int
read() Reads a byte of data from this file. int
read(byte[] b) Reads up to int
read(byte[] b,
int off,
int len) Reads up to boolean
readBoolean() Reads a byte
readByte() Reads a signed eight-bit value from this file. char
readChar() Reads a character from this file. double
readDouble() Reads a float
readFloat() Reads a void
readFully(byte[] b) Reads void
readFully(byte[] b,
int off,
int len) Reads exactly int
readInt() Reads a signed 32-bit integer from this file. String
readLine() Reads the next line of text from this file. long
readLong() Reads a signed 64-bit integer from this file. short
readShort() Reads a signed 16-bit number from this file. int
readUnsignedByte() Reads an unsigned eight-bit number from this file. int
readUnsignedShort() Reads an unsigned 16-bit number from this file. String
readUTF() Reads in a string from this file. void
seek(long pos) Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. void
setLength(long newLength) Sets the length of this file. int
skipBytes(int n) Attempts to skip over void
write(byte[] b) Writes void
write(byte[] b,
int off,
int len) Writes void
write(int b) Writes the specified byte to this file. void
writeBoolean(boolean v) Writes a void
writeByte(int v) Writes a void
writeBytes(String s) Writes the string to the file as a sequence of bytes. void
writeChar(int v) Writes a void
writeChars(String s) Writes a string to the file as a sequence of characters. void
writeDouble(double v) Converts the double argument to a void
writeFloat(float v) Converts the float argument to an void
writeInt(int v) Writes an void
writeLong(long v) Writes a void
writeShort(int v) Writes a void
writeUTF(String str) Writes a string to the file using modified UTF-8 encoding in a machine-independent manner. What happens when a piece of data is written to a file?When a piece of data is written to a file, it is copied from a variable in RAM to the file. The process of retrieving data from a file is known as reading data from the file.
What is the term used to describe a file that data is read from?True. The term "output file" is used to describe a file that data is read from.
Which type of data file access allows access to any piece of data in the file without reading the data that comes before it?1. When working with a sequential access file, you can jump directly to any piece of data in the file without reading the data that comes before it. 2. When an input file is opened, its read position is initially set to the first item in the file.
When a CPU executes each instruction in a program it uses a process known as the?The CPU runs instructions using a "fetch-execute" cycle: the CPU gets the first instruction in the sequence, executes it (adding two numbers or whatever), then fetches the next instruction and executes it, and so on.
|