|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.io.Writer
ewe.io.TextWriter
A TextWriter is used for writing Unicode text files that may be encoded as bytes in any format. It uses a TextCodec for encoding the characters into bytes to be sent to the output Stream and so you must provide the correct Codec for the file. The only Codecs provided by the Ewe library are the JavaUtf8Codec (which will encode ANY Unicode text) and AsciiCodec (which only encodes Unicode values from 0 to 255 as their exact byte values).
By default, a JavaUtf8Codec is used for encoding.
| Field Summary | |
protected boolean |
closed
This indicates that the close() method has already been called. |
TextCodec |
codec
This is the codec used for encoding outgoing data characters into bytes. |
protected OutputStream |
output
This is the underlying stream, or the "stream" Stream may be used instead. |
protected Stream |
stream
This is the underlying stream, or the "output" OutputStream may be used instead. |
| Fields inherited from class ewe.io.Writer |
lock |
| Constructor Summary | |
TextWriter(BasicStream out)
Create a new TextWriter to write to the specified Stream. |
|
TextWriter(OutputStream out)
Create a new TextWriter to write to the specified Stream. |
|
TextWriter(String path,
boolean append)
Create a new TextWriter to write to the specified file name. |
|
| Method Summary | |
void |
close()
Close the TextWriter and the underlying Stream. |
void |
flush()
Flush any waiting data to the underlying output Stream. |
void |
print(String text)
Write out a String of text. |
void |
println()
Output a line-feed (end of line) character. |
void |
println(String text)
Write out a String of text followed by a line-feed.. |
void |
write(char[] chars,
int offset,
int length)
Write out a number of characters. |
static void |
writeAll(String text,
Object basicStreamOrOutputStream,
TextCodec codec)
Write an entire string to a stream. |
| Methods inherited from class ewe.io.Writer |
getLock, write, write, write, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
protected Stream stream
protected OutputStream output
protected boolean closed
public TextCodec codec
| Constructor Detail |
public TextWriter(BasicStream out)
out - The output Stream.public TextWriter(OutputStream out)
out - The OutputStream.
public TextWriter(String path,
boolean append)
throws IOException
path - The path of the file.append - true to append to an existing file, false to overwrite.
IOException - if the file could not be opened for writing.| Method Detail |
public void flush()
throws IOException
flush in class WriterIOException - If an I/O error occurs
public void write(char[] chars,
int offset,
int length)
throws IOException
write in class Writerchars - The characters to be writen.offset - The location in the chars to start writing from.length - The number of characters to write.
IOException - If there is an error writing the data.
public void print(String text)
throws IOException
text - The String to write out.
IOException - If there is an error writing the data.
public void println(String text)
throws IOException
text - The String to write out.
IOException - If there is an error writing the data.
public void println()
throws IOException
IOException - If there is an error writing the data.
public void close()
throws IOException
close in class WriterIOException - on error.
public static void writeAll(String text,
Object basicStreamOrOutputStream,
TextCodec codec)
throws IOException
basicStreamOrOutputStream - This must be a BasicStream or an OutputStream object.codec - The codec to use or null for the default Java UTF8 codec.
IOException - if an error occured during writing or encoding.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||