Contents

StringIO

This module contains file I/O related functions that read and write contents of textual files into/from String instances.

Reading

readLines :: String -> <Proc> [String]

readLines "filename" reads all lines of the file specified by fileName. The file contents are expected to be UTF-8 encoded.

readLinesWithCharset :: String -> String -> <Proc> [String]

readLinesWithCharset "charset" "fileName" reads all lines of the file specified by fileName into a list of lines. The contents of the file are decoded using the specified charset.

readContentsWithCharset :: String -> String -> <Proc> String

readContentsWithCharset "charset" "fileName" reads full contents of the file specified by fileName. The contents of the file are decoded using the specified character set.

Writing

writeLines :: String -> [String] -> <Proc> ()

writeLines "fileName" lines creates new or overwrites existing file specified by fileName with the specified list of strings written as lines, i.e. separated by '\n' (line feed). The written text will be UTF-8 encoded.

appendLine :: String -> String -> <Proc> ()

appendLine "fileName" line appends the specified line of text to the file with name fileName and appends a '\n' (line feed) after the text. The appended content will be UTF-8 encoded.

appendContent :: String -> String -> <Proc> ()

appendContent "fileName" content only appends the specified content to the file with name fileName. The appended content will be UTF-8 encoded.

appendContentWithCharset :: String -> String -> String -> <Proc> ()

appendContentWithCharset "charset name" "fileName" content appends content to the file with name fileName. The appended content will be encoded using the given character set.

setContent :: String -> String -> <Proc> ()

setContent "fileName" "contents" writes contents into the file specified by fileName. The written content will be UTF-8 encoded.

setContentWithCharset :: String -> String -> String -> <Proc> ()

setContentWithCharset "charset name" "file" "contents" writes contents into the specified file using the given character set.