Object REXX supports a stream I/O model. In the stream model, your program reads data from various devices (such as hard disks, CD-ROMs, and keyboards) as a continuous stream of characters. Your program also writes data as a continuous stream of characters.
In the stream model, a text file is represented as a stream of characters with special new-line characters marking the end of each "line" of text in the stream. A binary file is simply a stream of characters without an inherent line structure. REXX lets you read streams as lines or as characters.
To support the stream model, Object REXX includes a Stream class and many methods to use on stream objects. To input or output data, you first create an instance of the Stream class that represents the device or file you want to use. For example, the following clause creates a stream object for the file C:\CONFIG.SYS:
/* Create a stream object for CONFIG.SYS */ file=.stream~new('c:\config.sys')
Then you send the stream object messages that are appropriate for the device or data. CONFIG.SYS is a text file, so you would normally use methods that read or write data as lines. Some of these methods are LINES, LINEIN, and LINEOUT.
If the stream represented a binary file (such as a WAV, GIF, TIF, AVI, or EXE file), you would use methods that read and write data as characters. Some of these methods are CHARS, CHARIN, and CHAROUT.
The Stream class includes other methods for opening and closing streams, flushing buffers, seeking, retrieving stream status, and other input/output operations.
Many of the methods of the Stream class are also available as REXX built-in functions. While you can use the functions, using the Stream class is preferred. In any case, you should not intermix the use of functions and methods on the same stream. Doing so yields unpredictable results.