|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream structure.ReadStream
public class ReadStream
A ReadStream provides reasonable access to the typewritten data on an input stream. Usually, a ReadStream is constructed with no parameters, causing the ReadStream to open access to System.in.
The access methods allow one to read from the stream, much as is done with Pascal.
Typical usage:
To read everything typed in System.in into a vector we could use the following:
public static void main(String[] argv){ ReadStream r = newReadStream()
; Vector buffer = new Vector(); while(!r.eof()
){ buffer.add(r.readString()
); } System.out.println(buffer); System.out.println(buffer.size()); } }
Constructor Summary | |
---|---|
ReadStream()
Construct an empty ReadStream, obtaining info from System.in. |
|
ReadStream(java.io.InputStream strm)
Construct a ReadStream based on pre-existing input stream. |
Method Summary | |
---|---|
boolean |
eof()
Determine if we've seen end-of-file. |
boolean |
eoln()
Return true if the next character to be read is an end-of-line mark. |
char |
getFirst()
Read (but don't consume) next char in stream. |
void |
pushbackChar(char c)
Return character to input stream for reading at later time. |
boolean |
readBoolean()
Read the next word "true" or "false" as a boolean. |
char |
readChar()
Read next character, whitespace or not. |
double |
readDouble()
Reads the next double value from input stream. |
float |
readFloat()
Read floating point value from input (Currently not working). |
void |
readFully(byte[] b)
Read an array of bytes from input. |
void |
readFully(byte[] b,
int off,
int len)
Read input into byte array. |
int |
readInt()
Reads an integer from input stream. |
java.lang.String |
readLine()
Read the remainder of line, including end-of-line mark. |
void |
readln()
Read characters up to and including the end-of-line mark. |
long |
readLong()
Read a (potentially long) input. |
short |
readShort()
Reads an integer from input stream. |
java.lang.String |
readString()
Skip white space and read in the next non-whitespace word as a string. |
java.lang.String |
readUTF()
Read unicode from input. |
void |
skipWhite()
Consume all the white-space characters until EOF or other data. |
Methods inherited from class java.io.FilterInputStream |
---|
available, close, mark, markSupported, read, read, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReadStream()
public ReadStream(java.io.InputStream strm)
strm
- The pre-existing input stream.Method Detail |
---|
public boolean eof()
public char getFirst()
public boolean eoln()
public void readln()
public void skipWhite()
public java.lang.String readString()
public boolean readBoolean()
public char readChar()
public void pushbackChar(char c)
c
- The character to push back onto input stream.public double readDouble()
public float readFloat()
public void readFully(byte[] b) throws java.io.IOException
b
- The array of bytes; holds result.
java.io.IOException
public void readFully(byte[] b, int off, int len) throws java.io.IOException
b
- Target array of bytes.off
- Offset into byte array to start reading.len
- Number of bytes to be read.
java.io.IOException
public short readShort()
public int readInt()
public long readLong()
public java.lang.String readLine()
public java.lang.String readUTF() throws java.io.IOException
java.io.IOException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |