RandomAccessFile中read函数

问题:

raf = new RandomAccessFile(file, "r");实例化后需要try/catch但这样后再try/catch外的函数中就找不到raf,会显示raf没有实例化未定义。所以在try/catch中raf = new RandomAccessFile(file, "r");后紧接着就要使用raf.read();函数。其中raf.read函数用法为raf.read()

final FileDescriptor getFD()
Gets this file's FileDescriptor.
long getFilePointer()
Gets the current position within this file.
long length()
Returns the length of this file in bytes.
int read(byte[] buffer, int byteOffset, int byteCount)
Reads up to byteCount bytes from the current position in this file and stores them in the byte array buffer starting at byteOffset.
int read(byte[] buffer)
Reads bytes from the current position in this file and stores them in the byte array buffer.
int read()
Reads a single byte from the current position in this file and returns it as an integer in the range from 0 to 255.

你可能感兴趣的:(RandomAccessFile中read函数)