Return the contents of PATHNAME as a string.
(defun read-string-from-file (pathname &key (buffer-size 4096)
"Return the contents of PATHNAME as a string."
(with-input-from-file (file-stream pathname)
(let ((buffer (make-array buffer-size :element-type element-type)))
(loop for bytes-read = (read-sequence buffer file-stream)
do (write-sequence buffer datum :start 0 :end bytes-read)
while (= bytes-read buffer-size))))))Source Context