The Stream Object
Resin Stream instances are roughly comparable to a combination of the Java `RandomAccessFile`, `Reader` and `Writer` classes, or to put it another way, to the C language's `FILE` object. Stream instances are always buffered.
Stream instance properties
readByte() | Reads a single byte from the stream and returns it as a number. It returns -1 on end of file.
read([n]) | Reads n characters from the stream and returns them as a string. If n is omitted, reads a single character.
readln() | Reads a line from the stream and returns a string. Lines are delimited by a linefeed ('\n').
available() | This function returns the bytes available to be read.
position | The position in the file counted as bytes from the beginning of the file.
inputStream | Returns a JDK InputStream tied to this stream.
writeByte(b) | Writes the byte to the stream.
write(string) | Writes the string to the stream.
writeln(string) | Writes the string to the stream, appending a newline.
printf(fmt, ...) | Writes formatted output to the stream.
writeStream(stream) | Writes the entire contents of stream to the stream.
writeFile(file) | Writes the entire contents of the File object file to the stream.
outputStream | Returns a JDK OutputStream tied to the stream.
flush() | Flushes output to the stream.
close() | Closes the stream.
Stream instance properties | Resin 1.0
### readByte()
Reads a single byte from the stream and returns it as a number. It returns -1 on end of file.
### read([n])
Reads n characters from the stream and returns them as a string. If n is omitted, reads a single character. It returns null on end of file.
### readln()
Reads a line from the stream and returns a string. Lines are delimited by a linefeed ('\n'). The trailing cr-lf is stripped from the string. Returns null on end of file.
### available()
This function returns the bytes available to be read. The only guarantee is that if there are bytes to be read available will be non-zero.
### position
The position in the file counted as bytes from the beginning of the file. Reading it will return the current position and writing to it will set the position. For some streams, like standard input, standard output and tcp/ip streams this returns a read-only value of 0.
### inputStream
Returns a JDK InputStream tied to this stream.
### writeByte(b)
Writes the byte to the stream.
out.writeByte(65)
A
### write(string)
Writes the string to the stream.
out.write("2 + 2 = ", 2 + 2) out.writeln("; 4 + 4 = ", 4 + 4)
2 + 2 = 4; 4 + 4 = 8
### writeln(string)
Writes the string to the stream, appending a newline.
out.writeln("2 + 2 = ", 2 + 2) out.writeln("4 + 4 = ", 4 + 4)
2 + 2 = 4 4 + 4 = 8
### printf(fmt, ...)
Writes formatted output to the stream. Resin's printf function follows C's.
### writeStream(stream)
Writes the entire contents of stream to the stream.
### writeFile(file)
Writes the entire contents of the File object file to the stream. `writeFile` opens the file object file as in `openRead`. It copies the entire contents of file to the stream as `writeStream`. Finally, it closes the stream. The following example writes the home page of caucho.com to out.
out.writeFile(File("http://www.caucho.com"))
### outputStream
Returns a JDK OutputStream tied to the stream.
### flush()
Flushes output to the stream.
### close()
Closes the stream.
Copyright © 1998-2000 Caucho Technology. All rights reserved. Last modified: Fri, 31 Mar 2000 18:55:58 -0800 (PST)