public class RAFolderInputStream extends RAInputStream
| 构造器和说明 |
|---|
RAFolderInputStream(java.io.File file) |
RAFolderInputStream(java.util.HashSet<RAFolderInputStream> manager,
java.io.File file) |
| 限定符和类型 | 方法和说明 |
|---|---|
int |
available()
Returns the number of bytes that can be read (or skipped over) from this
random access input stream without blocking by the next caller of a
method for this input stream.
|
void |
close()
Close the stream
|
java.lang.String |
getName() |
long |
getOffset() |
long |
getStreamLength() |
long |
length() |
int |
read()
The same behavior as InputStream.read().
|
int |
read(byte[] b,
int off,
int len)
The same behavior as InputStream.read(byte b[], int off, int len ).
|
void |
readFully(byte[] b,
int off,
int len)
The same behavior as RandomAccessFile.readFully(byte b[], int off, int len)
Reads exactly
len bytes from this file into the byte
array, starting at the current file pointer. |
int |
readInt()
Instead of calling randomAccessFile.readInt, we implement it in a better way (much better performace.)
|
long |
readLong()
Reads a signed 64-bit integer from this file.
|
void |
refresh() |
void |
seek(long localPos)
Move the file pointer to the new location in the stream
|
public RAFolderInputStream(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic RAFolderInputStream(java.util.HashSet<RAFolderInputStream> manager, java.io.File file) throws java.io.IOException
file - - a regular file (i.e. stream) in the folderjava.io.FileNotFoundExceptionjava.io.IOExceptionpublic java.lang.String getName()
public void refresh()
throws java.io.IOException
refresh 在类中 RAInputStreamjava.io.IOExceptionpublic int read()
throws java.io.IOException
int in the range 0 to
255. If no byte is available because the end of the stream
has been reached, the value -1 is returned. This method
blocks until input data is available, the end of the stream is detected,
or an exception is thrown.
A subclass must provide an implementation of this method.
read 在类中 java.io.InputStream-1 if the end of the
stream is reached.java.io.IOException - if an I/O error occurs.public int read(byte[] b,
int off,
int len)
throws java.io.IOException
-1 is returned. This method blocks until input data
is available, the end of the stream is detected, or an exception is thrown.
A subclass must provide an implementation of this method.
read 在类中 java.io.InputStream-1
if there is no more data because the end of the stream has been reachedjava.io.IOException - if an I/O error occurs.public int readInt()
throws java.io.IOException
b1,
b2, b3, and b4, where
0 <= b1, b2, b3, b4 <= 255,
then the result is equal to:
(b1 << 24) | (b2 << 16) + (b3 << 8) + b4
This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.
readInt 在类中 RAInputStreamint.java.io.EOFException - if this stream reaches the end before reading
four bytes.java.io.IOException - if an I/O error occurs.public long readLong()
throws java.io.IOException
b1, b2, b3,
b4, b5, b6,
b7, and b8, where:
0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,
then the result is equal to:
((long)b1 << 56) + ((long)b2 << 48)
+ ((long)b3 << 40) + ((long)b4 << 32)
+ ((long)b5 << 24) + ((long)b6 << 16)
+ ((long)b7 << 8) + b8
This method blocks until the eight bytes are read, the end of the stream is detected, or an exception is thrown.
readLong 在类中 RAInputStreamlong.java.io.EOFException - if this file reaches the end before reading
eight bytes.java.io.IOException - if an I/O error occurs.public final void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes from this file into the byte
array, 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 在类中 RAInputStreamb - 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.public long getStreamLength()
throws java.io.IOException
java.io.IOExceptionpublic void seek(long localPos)
throws java.io.IOException
seek 在类中 RAInputStreamlocalPos - - the new local postion in the stream. The localPos starts from 0.java.io.IOExceptionpublic long getOffset()
throws java.io.IOException
getOffset 在类中 RAInputStreamjava.io.IOExceptionpublic long length()
throws java.io.IOException
length 在类中 RAInputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseableclose 在类中 java.io.InputStreamjava.io.IOExceptionpublic int available()
throws java.io.IOException
RAInputStream
This abstract class is extended by RAFolderInputStream and
RAFileInputStream
The available method returns -1 when no
more data because the end of the stream has been reached.
and returns Integer.MAX_VALUE when bytes of data is larger
then Integer.MAX_VALUE.
available 在类中 RAInputStreamjava.io.IOExceptionCopyright © 2008 Actuate Corp. All rights reserved.