Description Usage Arguments Fields and Methods Author(s) Examples
Package: R.io
Class FileOutputStream
Object
~~|
~~+--
OutputStream
~~~~~~~|
~~~~~~~+--
FileOutputStream
Directly known subclasses:
public static class FileOutputStream
extends OutputStream
Class providing an output stream of bytes to a file.
1 |
file |
A |
Methods:
close | Flushes and closes the file output stream. | |
finalize | Finalizes the stream by first closing it. | |
write | Writes one or more bytes to the file output stream. | |
Methods inherited from OutputStream:
close, finalize, flush, write
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clone, detach, equals, extend, finalize, gc, getEnvironment, getFields, getInstanciationTime, getStaticInstance, hasField, hashCode, ll, load, objectSize, print, save
Henrik Bengtsson (http://www.braju.com/R/)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | file <- File$createTempFile("file")
fout <- FileOutputStream(file)
# Writes the bytes 0,1,2,...,255,0,1 to the temporary file
bfr <- 0:257
write(fout, bfr)
close(fout)
cat("Wrote the bytes to ", getPath(file), ".\n", sep="")
cat("Length of the file is ", size(file), " bytes.\n", sep="")
cat("Reading the bytes from ", getPath(file), ".\n", sep="")
fin <- FileInputStream(file)
while((bfr <- read(fin, len=4096))[1] != -1)
cat(formatC(bfr, width=3))
cat("\n")
close(fin)
# Deletes the temporary file
erase(file)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.