|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Writer
edu.rice.cs.plt.io.DirectWriter
public abstract class DirectWriter
A Writer that supports writing directly from a Reader. This class
provides default implementations defined in terms of Reader and Writer
methods. Subclasses can override (at least) writeAll(Reader, char[]) and
write(Reader, int, char[]) to provide better implementations (by, for example,
not invoking Writer.write(char[])).
DirectOutputStream,
DirectReader,
DirectInputStream| Field Summary | |
|---|---|
protected static int |
DEFAULT_BUFFER_SIZE
|
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
DirectWriter()
|
|
| Method Summary | |
|---|---|
int |
write(java.io.Reader r,
int chars)
Write some number of characters, using the provided Reader as input. |
int |
write(java.io.Reader r,
int chars,
char[] buffer)
Write some number of characters, using the provided Reader as input. |
int |
write(java.io.Reader r,
int chars,
int bufferSize)
Write some number of characters, using the provided Reader as input. |
int |
writeAll(java.io.Reader r)
Write the full contents of the given Reader to this writer. |
int |
writeAll(java.io.Reader r,
char[] buffer)
Write the full contents of the given Reader to this writer. |
int |
writeAll(java.io.Reader r,
int bufferSize)
Write the full contents of the given Reader to this writer. |
| Methods inherited from class java.io.Writer |
|---|
append, append, append, close, flush, write, write, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int DEFAULT_BUFFER_SIZE
| Constructor Detail |
|---|
public DirectWriter()
| Method Detail |
|---|
public int write(java.io.Reader r,
int chars)
throws java.io.IOException
Reader as input. Fewer characters
may be written if the reader has fewer available. The default implementation
invokes write(Reader, int, int) with the minimum of chars and
DEFAULT_BUFFER_SIZE. Subclasses that do not rely on a buffer in
write(Reader, int, char[]) should override this method.
r - A reader to be read fromchars - The number of characters to write
-1 if the reader is at the end of file; otherwise, the number of characters written
java.io.IOException - If an error occurs during reading or writing
public int write(java.io.Reader r,
int chars,
int bufferSize)
throws java.io.IOException
Reader as input. Fewer characters
may be written if the reader has fewer available. The default implementation
invokes write(Reader, int, char[]) with a newly-allocated array of the given size.
Subclasses that do not rely on a buffer in write(Reader, int, char[]) should override
this method.
r - A reader to be read fromchars - The number of characters to writebufferSize - The size of buffer to use (if necessary). Smaller values may reduce the amount of
memory required; larger values may increase performance on large readers
-1 if the reader is at the end of file; otherwise, the number of characters written
java.io.IOException - If an error occurs during reading or writing
java.lang.IllegalArgumentException - If bufferSize <= 0
public int write(java.io.Reader r,
int chars,
char[] buffer)
throws java.io.IOException
Reader as input. Fewer characters
may be written if the reader has fewer available. The given buffer is useful in repeated
write invocations to avoid unnecessary memory allocation. The default implementation
repeatedly fills the given buffer via a Reader.read(char[], int, int) operation, then
writes it via Writer.write(char[], int, int). Subclasses that do not require an external
buffer should override this method.
r - A reader to be read fromchars - The number of characters to writebuffer - A buffer used to copy characters from the reader to this writer. Note that this is only
used to avoid unnecessary memory allocation. No assumptions are made about the buffer's
contents (which may be overwritten), and no assumptions should be made about the contents
of the buffer after the method invocation.
-1 if the reader is at the end of file; otherwise, the number of characters written
java.io.IOException - If an error occurs during reading or writing
java.lang.IllegalArgumentException - If buffer has size 0
public int writeAll(java.io.Reader r)
throws java.io.IOException
Reader to this writer. The method will block
until an end-of-file is reached. The default implementation invokes
writeAll(Reader, int) with DEFAULT_BUFFER_SIZE. Subclasses that know the
size of this reader's remaining contents, or that do not rely on a buffer in
writeAll(Reader, char[]), should override this method.
r - A reader to be read from
-1 if the reader is at the end of file; otherwise, the number of characters written
(or, if the number is too large, Integer.MAX_VALUE)
java.io.IOException - If an error occurs during reading or writing
public int writeAll(java.io.Reader r,
int bufferSize)
throws java.io.IOException
Reader to this writer. The method will block
until an end-of-file is reached. The default implementation invokes
writeAll(Reader, char[]) with a newly-allocated array of the given size. Subclasses
that do not rely on a buffer in writeAll(Reader, char[]) should override this method.
r - A reader to be read frombufferSize - The size of buffer to use (if necessary). Smaller values may reduce the amount of
memory required; larger values may increase performance on large readers
-1 if the reader is at the end of file; otherwise, the number of characters written
(or, if the number is too large, Integer.MAX_VALUE)
java.io.IOException - If an error occurs during reading or writing
java.lang.IllegalArgumentException - If bufferSize <= 0
public int writeAll(java.io.Reader r,
char[] buffer)
throws java.io.IOException
Reader to this writer. The given buffer is useful
in repeated writeAll invocations to avoid unnecessary memory allocation. The method will
block until an end-of-file is reached. The default implementation repeatedly fills the given buffer
via a Reader.read(char[]) operation, then writes it via Writer.write(char[]).
Subclasses that do not require an external buffer should override this method.
r - A reader to be read frombuffer - A buffer used to copy characters from the reader to this writer. Note that this is only
used to avoid unnecessary memory allocation. No assumptions are made about the buffer's
contents (which may be overwritten), and no assumptions should be made about the contents
of the buffer after the method invocation.
-1 if the reader is at the end of file; otherwise, the number of characters written
(or, if the number is too large, Integer.MAX_VALUE)
java.io.IOException - If an error occurs during reading or writing
java.lang.IllegalArgumentException - If buffer has size 0
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||