Search code examples
programming-languages

Why byte level functions are required to read a text file?


Why byte level functions are required to read a text file. I mean after all it's a file containing an array of string. Then why it can't be stored in a string directly. Why in any language ( java, c, c++ or as3) byte level functions need to be used to read them ?

It could be quite easier if i could do something like this :

var a_str:String = new String();

var myFile:File  ;

a_str = String( myFile.read("xyz.txt") ) ;

trace ( a_str ) ; // << content of the file xyz.txt 

Solution

  • How do you store an end of file with characters? For any reasonable length sequence of characters you can think of, there is a possibility that it will appear in the text and be treated as an end of file and prematurely ending the file.