70 likes | 191 Views
Stream Classes. Object. InputStream. OutputStream. RandomAccess File. Reader. Writer. StreamTokenizer. FileInputStream. FileOutputStream. InputStreamReader. OutputStreamReader. FileReader. FileWriter. Streams of bytes. Streams of Characters. Java’s View of a File of n bytes. E O
E N D
Stream Classes Object InputStream OutputStream RandomAccess File Reader Writer StreamTokenizer FileInputStream FileOutputStream InputStreamReader OutputStreamReader FileReader FileWriter Streams of bytes Streams of Characters
Java’s View of a File of n bytes E O F n-1 0 2 ………………………………
InputStream/Reader public abstract int read() throws IOException Reads the next byte and returns its value (betweeen 0 and 255); returns –1 at the end. public void close() throws IOException Closes the input stream public void int available () throws IOException Returns the number of bytes that can be read from the input (Works only in InputStream)
OutputStream/Writer public abstract void write(int b) throws IOException Writes a byte (for OutputStream) or a character (for Writer) public void close () throws IOException Closes the output stream
StreamTokenizer Constant Description TT_WORD The token is a word. TT_NUMBER The token is a number. TT_EOL The end of the line has been read. TT_EOF The end of the file has been read. Variable Description int ttype Current token type double nval value of current token, if number String sval String that contains the characters of current token.