public class LogInputStream extends InputStream
InputStream
Modifier and Type | Field and Description |
---|---|
private InputStream |
in |
private int |
length |
Constructor and Description |
---|
LogInputStream(InputStream in,
int length)
Creates a log input file with the specified input stream.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of bytes that can be read without blocking.
|
private void |
badRead(int numBytes)
Throw exception for reading past end of log record.
|
void |
close()
Closes the input stream.
|
protected void |
finalize()
Closes the stream when garbage is collected.
|
int |
read()
Reads a byte of data.
|
int |
read(byte[] b)
Reads data into an array of bytes.
|
int |
read(byte[] b,
int off,
int len)
Reads data into an array of bytes.
|
long |
skip(long n)
Skips n bytes of input.
|
mark, markSupported, reset
private InputStream in
private int length
public LogInputStream(InputStream in, int length) throws IOException
in
- the input streamlength
- the total number of bytes allowed to be readIOException
- If an I/O error has occurred.private void badRead(int numBytes) throws LogException
numBytes
- number of bytes attempted to be readLogException
- Attempt to read past end of log.public int read() throws IOException, LogException
read
in class InputStream
LogException
- Attempt to read past end of log.IOException
- If an I/O error has occurred.public int read(byte[] b) throws IOException, LogException
read
in class InputStream
b
- the buffer into which the data is readLogException
- Attempt to read past end of log.IOException
- If an I/O error has occurred.public int read(byte[] b, int off, int len) throws IOException, LogException
read
in class InputStream
b
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes readLogException
- Attempt to read past end of log.IOException
- If an I/O error has occurred.public long skip(long n) throws IOException, LogException
skip
in class InputStream
n
- the number of bytes to be skippedLogException
- Attempt to read past end of log.IOException
- If an I/O error has occurred.public int available()
available
in class InputStream
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
protected void finalize() throws IOException
finalize
in class Object
IOException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.