C# Класс CSJ2K.j2k.io.BufferedRandomAccessFile

This class defines a Buffered Random Access File. It implements the BinaryDataInput and BinaryDataOutput interfaces so that binary data input/output can be performed. This class is abstract since no assumption is done about the byte ordering type (little Endian, big Endian). So subclasses will have to implement methods like readShort(), writeShort(), readFloat(), ...

BufferedRandomAccessFile (BRAF for short) is a RandomAccessFile containing an extra buffer. When the BRAF is accessed, it checks if the requested part of the file is in the buffer or not. If that is the case, the read/write is done on the buffer. If not, the file is uppdated to reflect the current status of the buffer and the file is then accessed for a new buffer containing the requested byte/bit.

Наследование: RandomAccessIO, EndianType
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
byteBuffer byte[]
byteBufferChanged bool
byte_Ordering int
isEOFInBuffer bool
maxByte int
offset int
position int

Открытые методы

Метод Описание
ToString ( ) : System.String

Returns a string of information about the file

close ( ) : void

Closes the buffered random access file

flush ( ) : void

Any data that has been buffered must be written (including buffering at the bit level), and the stream should be realigned at the byte level.

length ( ) : int

Returns the current length of the stream, in bytes, taking into account any buffering.

read ( ) : byte
readByte ( ) : byte

Reads an unsigned byte of data from the stream. Prior to reading, the stream is realigned at the byte level.

readDouble ( ) : double
readFloat ( ) : float
readFully ( byte b, int off, int len ) : void

Reads up to len bytes of data from this file into an array of bytes. This method reads repeatedly from the stream until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

readInt ( ) : int
readLong ( ) : long
readShort ( ) : short
readUnsignedByte ( ) : byte
readUnsignedInt ( ) : long
readUnsignedShort ( ) : int
seek ( int off ) : void

Moves the current position to the given offset at which the next read or write occurs. The offset is measured from the beginning of the stream.

skipBytes ( int n ) : int

Skips n bytes from the input. Prior to skipping, the input should be realigned at the byte level.

write ( byte b ) : void

Writes a byte to the stream. Prior to writing, the stream is realigned at the byte level.

write ( byte b, int offset, int length ) : void

Writes aan array of bytes to the stream. Prior to writing, the stream is realigned at the byte level.

write ( int b ) : void

Writes a byte to the stream. Prior to writing, the stream is realigned at the byte level.

writeByte ( int v ) : void

Writes the byte value of v (i.e., 8 least significant bits) to the output. Prior to writing, the output should be realigned at the byte level.

Signed or unsigned data can be written. To write a signed value just pass the byte value as an argument. To write unsigned data pass the int value as an argument (it will be automatically casted, and only the 8 least significant bits will be written).

writeDouble ( double param1 ) : void
writeFloat ( float param1 ) : void
writeInt ( int param1 ) : void
writeLong ( long param1 ) : void
writeShort ( int param1 ) : void

Защищенные методы

Метод Описание
BufferedRandomAccessFile ( IFileInfo file, System mode ) : System

Constructor. Uses the default value for the byte-buffer size (512 bytes).

BufferedRandomAccessFile ( IFileInfo file, System mode, int bufferSize ) : System

Constructor. Always needs a size for the buffer.

BufferedRandomAccessFile ( System.Stream stream, bool isReadOnly ) : System

Constructor. Uses the default value for the byte-buffer size (512 bytes).

BufferedRandomAccessFile ( System.Stream stream, bool isReadOnly, int bufferSize ) : System

Constructor. Always needs a size for the buffer.

BufferedRandomAccessFile ( System name, System mode ) : System

Constructor. Uses the default value for the byte-buffer size (512 bytes).

BufferedRandomAccessFile ( System name, System mode, int bufferSize ) : System

Constructor. Always needs a size for the buffer.

readNewBuffer ( int off ) : void

Reads a new buffer from the file. If there has been any changes made since the buffer was read, the buffer is first written to the file.

Описание методов

BufferedRandomAccessFile() защищенный Метод

Constructor. Uses the default value for the byte-buffer size (512 bytes).
If an I/O error ocurred. /// ///
protected BufferedRandomAccessFile ( IFileInfo file, System mode ) : System
file IFileInfo The file associated with the buffer /// ///
mode System "r" for read, "rw" or "rw+" for read and write mode /// ("rw+" opens the file for update whereas "rw" removes /// it before. So the 2 modes are different only if the /// file already exists). /// ///
Результат System

BufferedRandomAccessFile() защищенный Метод

Constructor. Always needs a size for the buffer.
If an I/O error ocurred. /// ///
protected BufferedRandomAccessFile ( IFileInfo file, System mode, int bufferSize ) : System
file IFileInfo The file associated with the buffer /// ///
mode System "r" for read, "rw" or "rw+" for read and write mode ("rw+" /// opens the file for update whereas "rw" removes it /// before. So the 2 modes are different only if the file /// already exists). /// ///
bufferSize int The number of bytes to buffer /// ///
Результат System

BufferedRandomAccessFile() защищенный Метод

Constructor. Uses the default value for the byte-buffer size (512 bytes).
If an I/O error ocurred. /// ///
protected BufferedRandomAccessFile ( System.Stream stream, bool isReadOnly ) : System
stream System.Stream The stream associated with the buffer /// ///
isReadOnly bool Indicates whether file is read-only or not.
Результат System

BufferedRandomAccessFile() защищенный Метод

Constructor. Always needs a size for the buffer.
If an I/O error ocurred. /// ///
protected BufferedRandomAccessFile ( System.Stream stream, bool isReadOnly, int bufferSize ) : System
stream System.Stream The stream associated with the buffer /// ///
isReadOnly bool Indicates whether file is read-only or not.
bufferSize int The number of bytes to buffer /// ///
Результат System

BufferedRandomAccessFile() защищенный Метод

Constructor. Uses the default value for the byte-buffer size (512 bytes).
If an I/O error ocurred. /// ///
protected BufferedRandomAccessFile ( System name, System mode ) : System
name System The name of the file associated with the buffer /// ///
mode System "r" for read, "rw" or "rw+" for read and write mode /// ("rw+" opens the file for update whereas "rw" removes /// it before. So the 2 modes are different only if the /// file already exists). /// ///
Результат System

BufferedRandomAccessFile() защищенный Метод

Constructor. Always needs a size for the buffer.
If an I/O error ocurred. /// ///
protected BufferedRandomAccessFile ( System name, System mode, int bufferSize ) : System
name System The name of the file associated with the buffer /// ///
mode System "r" for read, "rw" or "rw+" for read and write mode /// ("rw+" opens the file for update whereas "rw" removes /// it before. So the 2 modes are different only if the /// file already exists). /// ///
bufferSize int The number of bytes to buffer /// ///
Результат System

ToString() публичный Метод

Returns a string of information about the file
public ToString ( ) : System.String
Результат System.String

close() публичный Метод

Closes the buffered random access file
If an I/O error ocurred. /// ///
public close ( ) : void
Результат void

flush() публичный Метод

Any data that has been buffered must be written (including buffering at the bit level), and the stream should be realigned at the byte level.
If an I/O error ocurred. /// ///
public flush ( ) : void
Результат void

length() публичный Метод

Returns the current length of the stream, in bytes, taking into account any buffering.
If an I/O error ocurred. /// ///
public length ( ) : int
Результат int

read() публичный Метод

public read ( ) : byte
Результат byte

readByte() публичный Метод

Reads an unsigned byte of data from the stream. Prior to reading, the stream is realigned at the byte level.
If an I/O error ocurred. /// /// If the end of file was reached /// ///
public readByte ( ) : byte
Результат byte

readDouble() публичный абстрактный Метод

public abstract readDouble ( ) : double
Результат double

readFloat() публичный абстрактный Метод

public abstract readFloat ( ) : float
Результат float

readFully() публичный Метод

Reads up to len bytes of data from this file into an array of bytes. This method reads repeatedly from the stream until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.
If the end-of file was reached before /// getting all the necessary data. /// /// If an I/O error ocurred. /// ///
public readFully ( byte b, int off, int len ) : void
b byte The buffer into which the data is to be read. It must be long /// enough. /// ///
off int The index in 'b' where to place the first byte read. /// ///
len int The number of bytes to read. /// ///
Результат void

readInt() публичный абстрактный Метод

public abstract readInt ( ) : int
Результат int

readLong() публичный абстрактный Метод

public abstract readLong ( ) : long
Результат long

readNewBuffer() защищенный Метод

Reads a new buffer from the file. If there has been any changes made since the buffer was read, the buffer is first written to the file.
If an I/O error ocurred. /// ///
protected readNewBuffer ( int off ) : void
off int The offset where to move to. /// ///
Результат void

readShort() публичный абстрактный Метод

public abstract readShort ( ) : short
Результат short

readUnsignedByte() публичный Метод

public readUnsignedByte ( ) : byte
Результат byte

readUnsignedInt() публичный абстрактный Метод

public abstract readUnsignedInt ( ) : long
Результат long

readUnsignedShort() публичный абстрактный Метод

public abstract readUnsignedShort ( ) : int
Результат int

seek() публичный Метод

Moves the current position to the given offset at which the next read or write occurs. The offset is measured from the beginning of the stream.
If in read-only and seeking beyond EOF. /// /// If an I/O error ocurred. /// ///
public seek ( int off ) : void
off int The offset where to move to. /// ///
Результат void

skipBytes() публичный Метод

Skips n bytes from the input. Prior to skipping, the input should be realigned at the byte level.
If the end-of file was reached before /// all the bytes could be skipped. /// /// If an I/O error ocurred. /// ///
public skipBytes ( int n ) : int
n int The number of bytes to skip /// ///
Результат int

write() публичный Метод

Writes a byte to the stream. Prior to writing, the stream is realigned at the byte level.
If an I/O error ocurred. /// ///
public write ( byte b ) : void
b byte The byte to write. /// ///
Результат void

write() публичный Метод

Writes aan array of bytes to the stream. Prior to writing, the stream is realigned at the byte level.
If an I/O error ocurred. /// ///
public write ( byte b, int offset, int length ) : void
b byte The array of bytes to write. /// ///
offset int The first byte in b to write /// ///
length int The number of bytes from b to write /// ///
Результат void

write() публичный Метод

Writes a byte to the stream. Prior to writing, the stream is realigned at the byte level.
If an I/O error ocurred. /// ///
public write ( int b ) : void
b int The byte to write. The lower 8 bits of b are /// written. /// ///
Результат void

writeByte() публичный Метод

Writes the byte value of v (i.e., 8 least significant bits) to the output. Prior to writing, the output should be realigned at the byte level.

Signed or unsigned data can be written. To write a signed value just pass the byte value as an argument. To write unsigned data pass the int value as an argument (it will be automatically casted, and only the 8 least significant bits will be written).

If an I/O error ocurred. /// ///
public writeByte ( int v ) : void
v int The value to write to the output /// ///
Результат void

writeDouble() публичный абстрактный Метод

public abstract writeDouble ( double param1 ) : void
param1 double
Результат void

writeFloat() публичный абстрактный Метод

public abstract writeFloat ( float param1 ) : void
param1 float
Результат void

writeInt() публичный абстрактный Метод

public abstract writeInt ( int param1 ) : void
param1 int
Результат void

writeLong() публичный абстрактный Метод

public abstract writeLong ( long param1 ) : void
param1 long
Результат void

writeShort() публичный абстрактный Метод

public abstract writeShort ( int param1 ) : void
param1 int
Результат void

Описание свойств

byteBuffer защищенное свойство

Buffer of bytes containing the part of the file that is currently being accessed
protected byte[] byteBuffer
Результат byte[]

byteBufferChanged защищенное свойство

Boolean keeping track of whether the byte buffer has been changed since it was read.
protected bool byteBufferChanged
Результат bool

byte_Ordering защищенное свойство

protected int byte_Ordering
Результат int

isEOFInBuffer защищенное свойство

Whether the end of the file is in the current buffer or not
protected bool isEOFInBuffer
Результат bool

maxByte защищенное свойство

The maximum number of bytes that can be read from the buffer
protected int maxByte
Результат int

offset защищенное свойство

The current offset of the buffer (which will differ from the offset of the file)
protected int offset
Результат int

position защищенное свойство

The current position in the byte-buffer
protected int position
Результат int