This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to read a file in a string




On 12/11/2015 02:07 AM, Damien MATTEI wrote:
i have a method in a class to read a file (html page) in a string,method defined below:

((getHtmlCounterPage) ::java.lang.String
     (gnu.lists.FString:toString (read-string 65535 (open-input-file htmlCounterPage))))

is there a simplest way, that would be independent of 65535 (max size of file) bytes to read a file ?

You might find the path-data function convenient:
http://www.gnu.org/software/kawa/Reading-and-writing-whole-files.html

I haven't tested the following, but try it:

((getHtmlCounterPage) ::java.lang.String
   (path-data htmlCounterPage))

Where does 65535 come from?  True, read-string does allocate a buffer of the requested size,
but the max size of an array (or a string) is 2147483647.  So read-string is not a good
choice for reading an entire file of unknown size :-)
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]