read( ) example
Suppose you have a data file generated by a mainframe computer that has fixed-length records with no record breaks. You want to convert this file so that you have one record on each line. Use two File objects to read and write the file, adding line breaks as you write:
#define REC_LENGTH 80
#define IN_FILE "STUFF.REC"
#define OUT_FILE "STUFF.TXT"
fIn = new File( )
fOut = new File( )
fIn.open( IN_FILE );
fOut.create( OUT_FILE );
do while not fIn.eof( )
fOut.puts( fIn.read( REC_LENGTH )) // Read fixed length; write with line break
enddo
fIn.close( )
fOut.close( )