The R Project SVN R

Rev

Rev 74519 | Rev 82132 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 74519 Rev 74546
Line 74... Line 74...
74
\seealso{
74
\seealso{
75
  \code{\link{connections}}, \code{\link{writeLines}}, \code{\link{readBin}},
75
  \code{\link{connections}}, \code{\link{writeLines}}, \code{\link{readBin}},
76
  \code{\link{scan}}}
76
  \code{\link{scan}}}
77
 
77
 
78
\examples{
78
\examples{
79
fil <- tempfile(fileext = "ex.data")
79
fil <- tempfile(fileext = ".data")
80
cat("TITLE extra line", "2 3 5 7", "", "11 13 17", file = fil,
80
cat("TITLE extra line", "2 3 5 7", "", "11 13 17", file = fil,
81
    sep = "\n")
81
    sep = "\n")
82
readLines(fil, n = -1)
82
readLines(fil, n = -1)
-
 
83
unlink(fil) # tidy up
83
 
84
 
84
## difference in blocking
85
## difference in blocking
85
fil2 <- tempfile(fileext = "test1")
86
fil <- tempfile("test")
86
cat("123\nabc", file = fil2)
87
cat("123\nabc", file = fil)
87
readLines(fil2) # line with a warning
88
readLines(fil) # line with a warning
88
 
89
 
89
con <- file(fil2, "r", blocking = FALSE)
90
con <- file(fil, "r", blocking = FALSE)
90
readLines(con) # empty
91
readLines(con) # empty
91
cat(" def\n", file = fil2, append = TRUE)
92
cat(" def\n", file = fil, append = TRUE)
92
readLines(con) # gets both
93
readLines(con) # gets both
93
close(con)
94
close(con)
-
 
95
 
94
unlink(c(fil, fil2)) # tidy up
96
unlink(fil) # tidy up
95
 
97
 
96
\dontrun{
98
\dontrun{
97
# read a 'Windows Unicode' file
99
# read a 'Windows Unicode' file
98
A <- readLines(con <- file("Unicode.txt", encoding = "UCS-2LE"))
100
A <- readLines(con <- file("Unicode.txt", encoding = "UCS-2LE"))
99
close(con)
101
close(con)