|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.logAnalyzer.utils.FilesSetReader
This class is a wrapper is used to read a set of files. This implementation
acts as a wrapper supporting a small number of methods of the class
RandomAccessFile
.
Constructor Summary | |
FilesSetReader()
Default construtor. |
Method Summary | |
void |
close()
Closes this random access file stream and releases any system resources associated with the stream. |
long |
getFilePointer()
Returns the current offset in this log file. |
long |
length()
Returns the total length of files in the set. |
int |
read()
Reads a byte of data from this file using RandomAccessFile.read()
on the current file of the set of files. |
boolean |
readBoolean()
Reads one input byte using read() and returns true
if that byte is nonzero, false if that byte is zero. |
byte |
readByte()
Reads one input byte using read() and casts it to
byte . |
char |
readChar()
Reads an unsigned short using readUnsignedShort() and casts it
to char . |
double |
readDouble()
Reads a double from this file. |
float |
readFloat()
Reads a float from this file. |
void |
readFully(byte[] b)
Reads b.length bytes from this file into the byte array
using readFully(byte[], int, int) , starting at the current file
pointer. |
void |
readFully(byte[] b,
int off,
int len)
Reads exactly len bytes from this file into the byte array
unsing readByte() , starting at the current file pointer. |
int |
readInt()
Reads four input bytes using read() and combines them to
int . |
java.lang.String |
readLine()
Reads the next line of text from this file. |
long |
readLong()
Reads eight input bytes using read() twice and combines them to
long . |
short |
readShort()
Reads an unsigned short using readUnsignedShort() and casts it
to short . |
int |
readUnsignedByte()
Reads a single input byte using read() and returns it. |
int |
readUnsignedShort()
Reads two input bytes using read() and combines them to
int as an unsigned short. |
java.lang.String |
readUTF()
Reads in a string that has been encoded using a modified UTF-8 format. |
void |
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. |
void |
setFiles(java.io.File[] inputFiles)
Opens each input file as a new RandomAccessFile with mode "r". |
int |
skipBytes(int n)
Attempts to skip over n bytes of input discarding the
skipped bytes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FilesSetReader()
Method Detail |
public long getFilePointer() throws java.io.IOException
java.io.IOException
- If an I/O error occurs.RandomAccessFile.getFilePointer()
public void setFiles(java.io.File[] inputFiles) throws java.io.FileNotFoundException
RandomAccessFile
with mode "r".
inputFiles
- Files to read.
java.io.FileNotFoundException
- If one or more files exist but is a directory rather than
regular files, or cannot be opened or created for any other
reason.RandomAccessFile.RandomAccessFile(java.io.File, java.lang.String)
public void close() throws java.io.IOException
java.io.IOException
- If an I/O error occurs.java.io.Closeable#close()
public long length()
public int read() throws java.io.IOException
RandomAccessFile.read()
on the current file of the set of files. If the end of current file is
reached and the set contains more than one file, tries to read from the
next file.
-1
if the end of the
file has been reached.
java.io.IOException
- if an I/O error occurs. Not thrown if end-of-file has been
reached.RandomAccessFile.read()
public boolean readBoolean() throws java.io.IOException
read()
and returns true
if that byte is nonzero, false
if that byte is zero.
readBoolean
in interface java.io.DataInput
boolean
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readBoolean()
public byte readByte() throws java.io.IOException
read()
and casts it to
byte
.
readByte
in interface java.io.DataInput
byte
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readByte()
public char readChar() throws java.io.IOException
readUnsignedShort()
and casts it
to char
.
readChar
in interface java.io.DataInput
char
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readChar()
public double readDouble() throws java.io.IOException
double
from this file. This method reads a
long
value, starting at the current file pointer, as if by
the readLong
method and then converts that
long
to a double
using
Double.longBitsToDouble(long)
.
readDouble
in interface java.io.DataInput
double
value read.
java.io.IOException
- if an I/O error occurs.DataInput.readDouble()
public float readFloat() throws java.io.IOException
float
from this file. This method reads a
long
value, starting at the current file pointer, as if by
the readLong
method and then converts that
long
to a float
using
Float.intBitsToFloat(int)
.
readFloat
in interface java.io.DataInput
float
value read.
java.io.IOException
- if an I/O error occurs.DataInput.readFloat()
public void readFully(byte[] b, int off, int len) throws java.io.IOException
len
bytes from this file into the byte array
unsing readByte()
, starting at the current file pointer. This
method reads repeatedly from the file until the requested number of bytes
are read. This method blocks until the requested number of bytes are
read, the end of the stream is detected, or an exception is thrown.
readFully
in interface java.io.DataInput
b
- the buffer into which the data is read.off
- the start offset of the data.len
- the number of bytes to read.
java.io.EOFException
- if this file reaches the end before reading all the bytes.
java.io.IOException
- if an I/O error occurs.DataInput.readFully(byte[], int, int)
public void readFully(byte[] b) throws java.io.IOException
b.length
bytes from this file into the byte array
using readFully(byte[], int, int)
, starting at the current file
pointer.
readFully
in interface java.io.DataInput
b
- the buffer into which the data is read.
java.io.EOFException
- if this file reaches the end before reading all the bytes.
java.io.IOException
- if an I/O error occurs.DataInput.readFully(byte[])
public int readInt() throws java.io.IOException
read()
and combines them to
int
.
readInt
in interface java.io.DataInput
int
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readInt()
public java.lang.String readLine() throws java.io.IOException
readLine
in interface java.io.DataInput
java.io.IOException
- If an I/O error occurs.DataInput.readLine()
public long readLong() throws java.io.IOException
read()
twice and combines them to
long
.
readLong
in interface java.io.DataInput
long
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readLong()
public short readShort() throws java.io.IOException
readUnsignedShort()
and casts it
to short
.
readShort
in interface java.io.DataInput
short
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readShort()
public int readUnsignedByte() throws java.io.IOException
read()
and returns it.
readUnsignedByte
in interface java.io.DataInput
int
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readUnsignedByte()
public int readUnsignedShort() throws java.io.IOException
read()
and combines them to
int
as an unsigned short.
readUnsignedShort
in interface java.io.DataInput
int
value read.
java.io.EOFException
- if this file has reached the end.
java.io.IOException
- if an I/O error occurs.DataInput.readUnsignedShort()
public java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
java.io.IOException
DataInput.readUTF()
public void seek(long pos) throws java.io.IOException
pos
- The offset position, measured in bytes from the beginning of
the file, at which to set the file pointer.
java.io.IOException
- If an I/O error occurs.RandomAccessFile.seek(long)
public int skipBytes(int n) throws java.io.IOException
n
bytes of input discarding the
skipped bytes.
skipBytes
in interface java.io.DataInput
n
- the number of bytes to be skipped.
java.io.IOException
- if an I/O error occurs.DataInput.skipBytes(int)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |