Package org.eclipse.jgit.util.io
Class TimeoutInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.eclipse.jgit.util.io.TimeoutInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class TimeoutInputStream extends FilterInputStream
InputStream with a configurable timeout.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description TimeoutInputStream(InputStream src, InterruptTimer timer)
Wrap an input stream with a timeout on all read operations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getTimeout()
Get number of milliseconds before aborting a read.int
read()
int
read(byte[] buf)
int
read(byte[] buf, int off, int cnt)
void
setTimeout(int millis)
Set number of milliseconds before aborting a read.long
skip(long cnt)
-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
TimeoutInputStream
public TimeoutInputStream(InputStream src, InterruptTimer timer)
Wrap an input stream with a timeout on all read operations.- Parameters:
src
- base input stream (to read from). The stream must be interruptible (most socket streams are).timer
- timer to manage the timeouts during reads.
-
-
Method Detail
-
getTimeout
public int getTimeout()
Get number of milliseconds before aborting a read.- Returns:
- number of milliseconds before aborting a read.
-
setTimeout
public void setTimeout(int millis)
Set number of milliseconds before aborting a read.- Parameters:
millis
- number of milliseconds before aborting a read. Must be > 0.
-
read
public int read() throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] buf) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] buf, int off, int cnt) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
public long skip(long cnt) throws IOException
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
-