public final class BufferedRandomAccessFile extends RandomAccessFile
| Constructor and Description |
|---|
BufferedRandomAccessFile(File file,
String mode) |
BufferedRandomAccessFile(File file,
String mode,
int size) |
BufferedRandomAccessFile(String name,
String mode) |
BufferedRandomAccessFile(String name,
String mode,
int size) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the file, after flushing data in the buffer.
|
void |
flush()
If the file is writable, flush any bytes in the buffer that have not yet been written to disk.
|
long |
getFilePointer() |
long |
length()
Returns the length of the file, depending on whether buffer has more data (to be flushed).
|
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len)
Read specified number of bytes into given array starting at given offset.
|
void |
seek(long pos)
If the new seek position is in the buffer, adjust the currentPosition.
|
void |
write(byte[] b)
write an array of bytes to the buffer/file.
|
void |
write(byte[] b,
int off,
int len)
Write specified number of bytes into buffer/file, with given starting offset and length.
|
void |
write(int v)
write a byte to the buffer/file.
|
getChannel, getFD, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, setLength, skipBytes, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTFpublic BufferedRandomAccessFile(File file, String mode) throws IOException
file - - file namemode - - "r" for read only; "rw" for read writeIOExceptionpublic BufferedRandomAccessFile(File file, String mode, int size) throws IOException
file - - file namemode - - "r" for read only; "rw" for read writesize - - size/capacity of the buffer.IOExceptionpublic BufferedRandomAccessFile(String name, String mode) throws IOException
name - - name of the filemode - - "r" for read only; "rw" for read writeIOExceptionpublic BufferedRandomAccessFile(String name, String mode, int size) throws FileNotFoundException
name - - name of the filemode - - "r" for read only; "rw" for read writesize - - size/capacity of the bufferFileNotFoundExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class RandomAccessFileIOExceptionpublic void flush()
throws IOException
IOExceptionpublic void seek(long pos)
throws IOException
seek in class RandomAccessFilepos - - position in the file to be loaded to the buffer.IOExceptionpublic long getFilePointer()
getFilePointer in class RandomAccessFilepublic long length()
throws IOException
length in class RandomAccessFileIOExceptionpublic int read()
throws IOException
read in class RandomAccessFileIOExceptionpublic int read(byte[] b)
throws IOException
read in class RandomAccessFileb - - byte array into which to read data.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class RandomAccessFileb - - byte arrayoff - - start offsetlen - - length of bytes to be readIOExceptionpublic void write(int v)
throws IOException
write in interface DataOutputwrite in class RandomAccessFilev - - value to be writtenIOExceptionpublic void write(byte[] b)
throws IOException
write in interface DataOutputwrite in class RandomAccessFileb - - byte array with data to be writtenIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in interface DataOutputwrite in class RandomAccessFileb - - byte array with data to be writtenoff - - starting offset.len - - length of bytes to be writtenIOExceptionCopyright © 2024 The Apache Software Foundation. All rights reserved.