This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: how to read a file in a string
- From: Per Bothner <per at bothner dot com>
- To: Damien MATTEI <damien dot mattei at unice dot fr>, kawa at sourceware dot org
- Date: Fri, 11 Dec 2015 02:27:59 -0800
- Subject: Re: how to read a file in a string
- Authentication-results: sourceware.org; auth=none
- References: <566AA076 dot 7080008 at unice dot fr>
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/