public class TeeReader extends ProxyReader
ProxyReader.skip(long) or ProxyReader.mark(int)/ProxyReader.reset() on the reader will result on some characters from the
reader being skipped or duplicated in the writer.
The proxied reader is closed when the close() method is called on this proxy. You may configure whether the
reader closes the writer.
| Constructor and Description |
|---|
TeeReader(java.io.Reader input,
java.io.Writer branch)
Creates a TeeReader that proxies the given
Reader and copies all read characters to the given
Writer. |
TeeReader(java.io.Reader input,
java.io.Writer branch,
boolean closeBranch)
Creates a TeeReader that proxies the given
Reader and copies all read characters to the given
Writer. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the proxied reader and, if so configured, the associated writer.
|
int |
read()
Reads a single character from the proxied reader and writes it to the associated writer.
|
int |
read(char[] chr)
Reads characters from the proxied reader and writes the read characters to the associated writer.
|
int |
read(char[] chr,
int st,
int end)
Reads characters from the proxied reader and writes the read characters to the associated writer.
|
int |
read(java.nio.CharBuffer target)
Reads characters from the proxied reader and writes the read characters to the associated writer.
|
mark, markSupported, ready, reset, skippublic TeeReader(java.io.Reader input,
java.io.Writer branch)
Reader and copies all read characters to the given
Writer. The given writer will not be closed when this reader gets closed.input - reader to be proxiedbranch - writer that will receive a copy of all characters readpublic TeeReader(java.io.Reader input,
java.io.Writer branch,
boolean closeBranch)
Reader and copies all read characters to the given
Writer. The given writer will be closed when this reader gets closed if the closeBranch parameter is
true.input - reader to be proxiedbranch - writer that will receive a copy of all characters readcloseBranch - flag for closing also the writer when this reader is closedpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class ProxyReaderjava.io.IOException - if either the reader or writer could not be closedpublic int read()
throws java.io.IOException
read in class ProxyReaderjava.io.IOException - if the reader could not be read (or written)public int read(char[] chr)
throws java.io.IOException
read in class ProxyReaderchr - character bufferjava.io.IOException - if the reader could not be read (or written)public int read(char[] chr,
int st,
int end)
throws java.io.IOException
read in class ProxyReaderchr - character bufferst - start offset within the bufferend - maximum number of characters to readjava.io.IOException - if the reader could not be read (or written)public int read(java.nio.CharBuffer target)
throws java.io.IOException
read in interface java.lang.Readableread in class ProxyReadertarget - character bufferjava.io.IOException - if the reader could not be read (or written)Copyright © 2010 - 2023 Adobe. All Rights Reserved