File streams have the same protocol as CLDT Streams. For the complete set of methods supported by the Stream class, see "Stream classes". The following example uses a CfsReadFileStream to read data from an existing file, and a CfsWriteFileStream to write the data to a newly created file.
| oldData newData | (oldData := CfsReadFileStream open: 'oldData.txt') isCfsError ifTrue: [^self error: oldData message]. (newData := CfsWriteFileStream openEmpty: 'newData.txt') isCfsError ifTrue: [^self error: newData message].
newData nextPutAll: oldData contents. oldData close. newData close.
When used with file streams, the copyFrom:to:, position, position:, size, and skip: messages operate based upon byte indexes and sizes, not character and sizes. The other file stream operations operate in the same manner as the CLDT Stream protocols. For portability, use the next and next: protocols for stream positioning.