copystream {Rstreams} | R Documentation |
Copies bytes from the current position of one stream to the current position of another.
copystream(src, dest, nbytes)
src |
a stream previously opened in read mode. |
dest |
a stream previously opened in write mode. |
nbytes |
how many bytes to copy |
If you request copying more bytes than are present in the source, values will not be repeated: only what is there will be copied.
how many bytes were actually copied.
s <- openstream("mydata", "write") # Write the bytes from 1 to 100 to the file writeint(s, 1:100, 1) closestream(s) s1 <- openstream("mydata", "read") s2 <- openstream("newdata", "write") # Write a header in text, then copy the rest writechar(s2, "Header") copystream(s1, s2, summary(s1)$size) closestream(s1) closestream(s2) unlink(c("mydata", "newdata"))