org.archive.io
Class OriginSeekInputStream
java.lang.Object
java.io.InputStream
org.archive.io.SeekInputStream
org.archive.io.OriginSeekInputStream
- All Implemented Interfaces:
- it.unimi.dsi.fastutil.io.RepositionableStream, java.io.Closeable
public class OriginSeekInputStream
- extends SeekInputStream
Alters the origin of some other SeekInputStream. This class allows you
to completely ignore everything in the underlying stream before a specified
position, the origin position.
With the exception of position()
and position(long)
,
all of the methods in this class simply delegate to the underlying input
stream. The position
methods adjust the position of the
underlying stream relative to the origin specified at construction time.
- Author:
- pjack
Method Summary |
int |
available()
|
long |
position()
Returns the position of the underlying stream relative to the origin. |
void |
position(long p)
Positions the underlying stream relative to the origin. |
int |
read()
|
int |
read(byte[] buf)
|
int |
read(byte[] buf,
int ofs,
int len)
|
long |
skip(long count)
|
Methods inherited from class java.io.InputStream |
close |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OriginSeekInputStream
public OriginSeekInputStream(SeekInputStream input,
long origin)
throws java.io.IOException
- Constructor.
- Parameters:
input
- the underlying streamorigin
- the origin position
- Throws:
java.io.IOException
- if an IO error occurs
available
public int available()
throws java.io.IOException
- Overrides:
available
in class java.io.InputStream
- Throws:
java.io.IOException
read
public int read()
throws java.io.IOException
- Specified by:
read
in class java.io.InputStream
- Throws:
java.io.IOException
read
public int read(byte[] buf,
int ofs,
int len)
throws java.io.IOException
- Overrides:
read
in class java.io.InputStream
- Throws:
java.io.IOException
read
public int read(byte[] buf)
throws java.io.IOException
- Overrides:
read
in class java.io.InputStream
- Throws:
java.io.IOException
skip
public long skip(long count)
throws java.io.IOException
- Overrides:
skip
in class java.io.InputStream
- Throws:
java.io.IOException
position
public long position()
throws java.io.IOException
- Returns the position of the underlying stream relative to the origin.
- Returns:
- the relative position
- Throws:
java.io.IOException
- if an IO error occurs
position
public void position(long p)
throws java.io.IOException
- Positions the underlying stream relative to the origin.
In other words, this.position(0) resolves to input.position(origin),
where input is underlying stream and origin is the origin specified
at construction time.
- Parameters:
p
- the new position for this stream
- Throws:
java.io.IOException
- if an IO error occurs
Copyright © 2003-2011 Internet Archive. All Rights Reserved.