readLines(con = stdin(), n = -1L, ok = TRUE, warn = TRUE, encoding = "unknown", skipNul = FALSE)writeLines(text, con = stdout(), sep = "\n", useBytes = FALSE)
con | a connection. By default, the standard input for readLines and standard output for writeLines. |
n | an integer. The number of lines to read. The default -1L indicates readLines should read to the end of the file. |
ok | a logical value. If FALSE, and readLines reaches the end of the file before n lines are read, an error is generated. If TRUE (the default), no error is produced. |
warn | This argument is not yet implemented. logical value. If flush=TRUE, this generates a warning if the final line read does not include a terminating new-line character. |
encoding | This argument is not yet implemented. the string encoding (see Encoding) to use for newly-created strings. In TIBCO Enterprise Runtime for R, this argument is not implemented. |
text | the character vector to write. Each element is written as one line. |
sep | a character string. The separator between lines. The default is "\n". |
useBytes | In TIBCO Enterprise Runtime for R, this argument is ignored. All strings are written using the encoding of the output connection. |
skipNul | A logical value telling how to deal with nul (0) bytes in the input file. If FALSE then readLines will warn about nul bytes but will put them into the output strings, thus terminating the string early. If TRUE then the nul bytes will be omitted from the output strings. |
tfile <- tempfile() writeLines(paste(Sdatasets::state.abb, Sdatasets::state.name, sep=": ")[1:10], con=tfile) readLines(tfile) readLines(tfile, n=3)conn <- file(tfile, "rt") readLines(conn, n=2) # first 2 lines readLines(conn, n=2) # next 2 lines close(conn) unlink(tfile)