Package cn.nukkit.nbt.stream
Class BufferedRandomAccessFile
java.lang.Object
java.io.RandomAccessFile
cn.nukkit.nbt.stream.BufferedRandomAccessFile
- All Implemented Interfaces:
Closeable
,DataInput
,DataOutput
,AutoCloseable
A
BufferedRandomAccessFile
is like a
RandomAccessFile
, but it uses a private buffer so that most
operations do not require a disk access.
Note: The operations on this class are unmonitored. Also, the correct
functioning of the RandomAccessFile
methods that are not
overridden here relies on the implementation of those methods in the
superclass.
- Author:
- Avinash Lakshman ( [email protected]) & Prashant Malik ( [email protected] )
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBufferedRandomAccessFile
(File file, String mode) Open a newBufferedRandomAccessFile
onfile
in modemode
, which should be "r" for reading only, or "rw" for reading and writing.BufferedRandomAccessFile
(File file, String mode, int size) BufferedRandomAccessFile
(String name, String mode) Open a newBufferedRandomAccessFile
on the file namedname
in modemode
, which should be "r" for reading only, or "rw" for reading and writing.BufferedRandomAccessFile
(String name, String mode, int size) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
Flush any bytes in the file's buffer that have not yet been written to disk.long
long
length()
int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) byte
read1()
byte
void
seek
(long pos) void
seekUnsafe
(long pos) void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int b) void
writeCurrent
(byte b) Methods inherited from class java.io.RandomAccessFile
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, writeUTF
-
Field Details
-
BuffSz_
public static final int BuffSz_- See Also:
-
-
Constructor Details
-
BufferedRandomAccessFile
Open a newBufferedRandomAccessFile
onfile
in modemode
, which should be "r" for reading only, or "rw" for reading and writing.- Throws:
IOException
-
BufferedRandomAccessFile
- Throws:
IOException
-
BufferedRandomAccessFile
Open a newBufferedRandomAccessFile
on the file namedname
in modemode
, which should be "r" for reading only, or "rw" for reading and writing.- Throws:
IOException
-
BufferedRandomAccessFile
- Throws:
FileNotFoundException
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classRandomAccessFile
- Throws:
IOException
-
flush
Flush any bytes in the file's buffer that have not yet been written to disk. If the file was created read-only, this method is a no-op.- Throws:
IOException
-
seek
- Overrides:
seek
in classRandomAccessFile
- Throws:
IOException
-
seekUnsafe
- Throws:
IOException
-
getFilePointer
public long getFilePointer()- Overrides:
getFilePointer
in classRandomAccessFile
-
length
- Overrides:
length
in classRandomAccessFile
- Throws:
IOException
-
read
- Overrides:
read
in classRandomAccessFile
- Throws:
IOException
-
read1
- Throws:
IOException
-
read
- Overrides:
read
in classRandomAccessFile
- Throws:
IOException
-
read
- Overrides:
read
in classRandomAccessFile
- Throws:
IOException
-
readCurrent
- Throws:
IOException
-
writeCurrent
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classRandomAccessFile
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classRandomAccessFile
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classRandomAccessFile
- Throws:
IOException
-