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:
java.io.Closeable
,java.lang.AutoCloseable
public class TimeoutInputStream extends java.io.FilterInputStream
InputStream with a configurable timeout.
-
-
Constructor Summary
Constructors Constructor Description TimeoutInputStream(java.io.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()
int
read()
int
read(byte[] buf)
int
read(byte[] buf, int off, int cnt)
void
setTimeout(int millis)
long
skip(long cnt)
-
-
-
Constructor Detail
-
TimeoutInputStream
public TimeoutInputStream(java.io.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()
- Returns:
- number of milliseconds before aborting a read.
-
setTimeout
public void setTimeout(int millis)
- Parameters:
millis
- number of milliseconds before aborting a read. Must be > 0.
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] buf) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] buf, int off, int cnt) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
skip
public long skip(long cnt) throws java.io.IOException
- Overrides:
skip
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
-