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
파일 보기 프로젝트 열기: cureos/csj2k 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
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