|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.io.Reader
ewe.io.TextReader
A TextReader is used for reading Unicode text files that may be encoded as bytes in any format. It uses a TextCodec for decoding the byte encoded input 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 | |
int |
bufferSize
This is the buffer size to use when reading from the underlying stream. |
protected boolean |
closed
This indicates that the close() method has already been called. |
TextCodec |
codec
This is the codec used for decoding incoming data bytes into characters. |
protected InputStream |
input
This is the underlying stream, or the "stream" Stream may be used instead. |
protected Stream |
stream
This is the underlying stream, or the "input" InputStream may be used instead. |
| Fields inherited from class ewe.io.Reader |
lock |
| Constructor Summary | |
TextReader(BasicStream in)
Create a new TextReader to read from the specified Stream. |
|
TextReader(InputStream in)
Create a new TextReader to read from the specified InputStream. |
|
TextReader(String path)
Create a new TextReader to read from the specified file name. |
|
| Method Summary | |
void |
close()
Close the TextReader and the underlying Stream. |
int |
read(char[] dest,
int offset,
int length)
Read in a number of characters. |
String |
readAll()
Read in all the characters from this TextReader as a String. |
static String |
readAll(Object basicStreamOrInputStream,
TextCodec codec)
Read all the characters from the input stream using the specified TextCodec. |
int |
readDirect(char[] dest,
int offset,
int length)
Read in a number of characters. |
void |
readFully(char[] dest,
int offset,
int length)
Read in exactly the specified number of characters. |
String |
readFully(int length)
Read in exactly the specified number of characters as a String. |
String |
readLine()
Read a line of text. |
String |
readString(int length)
Read in up to the specified maximum number of characters as a String. |
boolean |
ready()
Tell whether this stream is ready to be read. |
| Methods inherited from class ewe.io.Reader |
getLock, mark, markSupported, read, read, reset, skip |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
protected Stream stream
protected InputStream input
protected boolean closed
public TextCodec codec
public int bufferSize
| Constructor Detail |
public TextReader(BasicStream in)
in - The input Stream.public TextReader(InputStream in)
in - The InputStream
public TextReader(String path)
throws IOException
path - the path to the file to read.| Method Detail |
public int readDirect(char[] dest,
int offset,
int length)
throws IOException
dest - The destination buffer for the characters.offset - The location in the destination to start writing to.length - The maximum number of characters to read.
IOException - If there is an error reading the data.
public String readLine()
throws IOException
IOException
public int read(char[] dest,
int offset,
int length)
throws IOException
read in class Readerdest - The destination buffer for the characters.offset - The location in the destination to start writing to.length - The maximum number of characters to read.
IOException - If there is an error reading the data.
public void close()
throws IOException
close in class ReaderIOException - on error.
public void readFully(char[] dest,
int offset,
int length)
throws IOException
dest - The destination for the characters.offset - The offset in the destination for the characters.length - The number of characters to read.
IOException - if an IO error occurs or if the
public String readFully(int length)
throws IOException
length - The number of characters to read.
IOException - if an IO error occurs or if the Stream ends before all the characters
could be read.
public String readString(int length)
throws IOException
length - The maximum number of characters to read.
IOException - if an IO error occurs.
public String readAll()
throws IOException
IOException - if an error occured during reading or decoding.
public static String readAll(Object basicStreamOrInputStream,
TextCodec codec)
throws IOException
basicStreamOrInputStream - This must be a BasicStream or an InputStream object.codec - The codec to use or null for the default Java UTF8 codec.
IOException - if an error occured during reading or decoding.
public boolean ready()
throws IOException
Reader
ready in class ReaderIOException - If an I/O error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||