public class InputStreamCopy
extends java.io.InputStream
Modifier and Type | Field and Description |
---|---|
private java.io.InputStream |
inputStream
Stream to read
|
private java.io.OutputStream |
outputStream
Stream where write
|
Constructor and Description |
---|
InputStreamCopy(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Constructs InputStreamCopy
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by
the next invocation of a method for this input stream.
|
void |
close()
Close the streams
|
void |
mark(int readlimit)
Mark aren't manage here, so do nothing
|
boolean |
markSupported()
Mark aren't manage, so not supported
|
int |
read()
Read one byte (Byte is also write in the output stream)
|
int |
read(byte[] b)
Read bytes and copy them in an array.
|
int |
read(byte[] b,
int off,
int len)
Read bytes and copy them in an array.
|
void |
reset()
Mark aren't manage, so do nothing
|
long |
skip(long n)
Skip several bytes.
|
private java.io.InputStream inputStream
private java.io.OutputStream outputStream
public InputStreamCopy(java.io.InputStream inputStream, java.io.OutputStream outputStream)
inputStream
- Stream to readoutputStream
- Stream where copypublic int available() throws java.io.IOException
Note that while some implementations of InputStream
will return the total number of bytes in the stream, many will
not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this
stream.
A subclass' implementation of this method may choose to throw an IOException
if this input stream has been closed
by invoking the close()
method.
The available
method for class InputStream
always returns 0
.
This method should be overridden by subclasses.
available
in class java.io.InputStream
0
when it reaches the end of the input stream.java.io.IOException
- if an I/O error occurs.InputStream.available()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
- On closing issueInputStream.close()
public void mark(int readlimit)
mark
in class java.io.InputStream
readlimit
- Ignore hereInputStream.mark(int)
public boolean markSupported()
markSupported
in class java.io.InputStream
false
InputStream.markSupported()
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
- On read/write issueInputStream.read()
public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
b
- Array to filljava.io.IOException
- On read/write issueInputStream.read(byte[])
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
b
- Array to filloff
- Offset to start to readlen
- Number of bytes to readjava.io.IOException
- On read/write issueInputStream.read(byte[], int, int)
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
- Not throwInputStream.reset()
public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
n
- Number of bytes to skipjava.io.IOException
- On read/write issueInputStream.skip(long)