public class RandomAccessReader extends Reader
RandomAccessReader extends Reader to
provide a means to create buffered Readers from
RandomAccessFiles.| Constructor and Description |
|---|
RandomAccessReader(RandomAccessFile raf)
Creates a new
RandomAccessReader wrapping the
RandomAccessFile and using a default-sized buffer
(8192 bytes). |
RandomAccessReader(RandomAccessFile raf,
int sz)
Creates a new
RandomAccessReader wrapping the
RandomAccessFile and using a buffer of the
specified size. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
close closes the underlying
RandomAccessFile. |
long |
getFilePointer()
getFilePointer returns the effective position of
the pointer in the underlying RandomAccessFile. |
long |
length()
length returns the length of the underlying
RandomAccessFile. |
int |
read()
read reads one byte from the underlying
RandomAccessFile. |
int |
read(char[] cbuf,
int off,
int len)
read reads from the underlying
RandomAccessFile into an array. |
void |
seek(long pos)
seek moves the pointer to the specified position. |
public RandomAccessReader(RandomAccessFile raf) throws IOException
RandomAccessReader wrapping the
RandomAccessFile and using a default-sized buffer
(8192 bytes).raf - a RandomAccessFile to wrap.IOException - if an error occurs.public RandomAccessReader(RandomAccessFile raf, int sz) throws IOException
RandomAccessReader wrapping the
RandomAccessFile and using a buffer of the
specified size.raf - a RandomAccessFile to wrap.sz - an int buffer size.IOExceptionpublic void close() throws IOException
close closes the underlying
RandomAccessFile.close in interface Closeableclose in interface AutoCloseableclose in class ReaderIOException - if an error occurs.public long length() throws IOException
length returns the length of the underlying
RandomAccessFile.long.IOException - if an error occurs.public final int read() throws IOException
read reads one byte from the underlying
RandomAccessFile.read in class Readerint, -1 if the end of the stream has
been reached.IOException - if an error occurs.public int read(char[] cbuf, int off, int len) throws IOException
read reads from the underlying
RandomAccessFile into an array.read in class Readercbuf - a char [] array to read into.off - an int offset in the array at which to
start storing chars.len - an int maximum number of char to read.int number of chars read, or -1 if the
end of the stream has been reached.IOException - if an error occurs.public long getFilePointer() throws IOException
getFilePointer returns the effective position of
the pointer in the underlying RandomAccessFile.long offset.IOException - if an error occurs.public void seek(long pos) throws IOException
seek moves the pointer to the specified position.pos - a long offset.IOException - if an error occurs.Copyright © 2014 BioJava. All rights reserved.