Skip to content

Instantly share code, notes, and snippets.

@KeenS
Last active November 28, 2016 02:00
Show Gist options
  • Save KeenS/8cf06002a9bb7f0ebeed08a549e0e346 to your computer and use it in GitHub Desktop.
Save KeenS/8cf06002a9bb7f0ebeed08a549e0e346 to your computer and use it in GitHub Desktop.
(defun read-file-into-string (file &key (buf-size 2048))
(with-output-to-string (s)
(with-open-file (f file)
(let ((buf (make-array 2048 :element-type 'base-char)))
(loop
:for size := (read-sequence buf f)
:while (= size buf-size)
:do (write-sequence buf s)
:finally
(write-sequence buf s :end size))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment