class LogInputStream extends InputStream implements LogStream
Modifier and Type | Field and Description |
---|---|
private byte[] |
buf
byte array buffer to hold read data
|
private static int |
BUFSIZE
Holds value of the internal buffer size to allocate
|
private int |
count
count of available bytes in the read buffer
|
private FileInputStream |
in
Underlying input stream from which bytes are read
|
private StreamKey |
key
Associated key for this stream object
|
private long |
offset
cumulative index/offset into this stream
|
private int |
pos
index/offset into the read buffer for the next set of bytes to read
|
Constructor and Description |
---|
LogInputStream(File file,
StreamKey key)
Simple constructor that accepts a File and StreamKey
arguments.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close()
Closes this LogStream object and releases any
associated resources.
|
Object |
getKey()
Returns the associated key for this LogStream.
|
long |
getOffset()
Returns the current "read" offset into this stream object.
|
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
private void |
refill()
Refills the internal buffer with any available bytes.
|
long |
skip(long n) |
mark, markSupported, reset
private static final int BUFSIZE
private byte[] buf
private int count
private int pos
private long offset
private FileInputStream in
private StreamKey key
public LogInputStream(File file, StreamKey key) throws FileNotFoundException
file
- the File to usedkey
- the associated key for this objectIllegalArgumentException
- if either the file or
key arguments are null.FileNotFoundException
- if the file exists but is a directory
rather than a regular file, does not exist but cannot
be created, or cannot be opened for any other reason.public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
LogStream
close
in interface LogStream
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
- if an I/O error occured while attempting
to close the LogStream.public long getOffset()
private void refill() throws IOException
IOException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.