OutputStream: Superclass of all classes representing an output stream of...

Description Usage Fields and Methods Author(s) Examples

Description

Package: R.io
Class OutputStream

Object
~~|
~~+--OutputStream

Directly known subclasses:
BufferedOutputStream, ConnectionOutputStream, FileOutputStream, FilterOutputStream, HtmlPrintStream, MultiOutputStream, PrintStream

public abstract static class OutputStream
extends Object

This abstract class is the superclass of all classes representing an output stream of bytes.

Usage

1

Fields and Methods

Methods:

close Closes the output stream.
finalize Finalize method that closes the stream when it is deleted.
flush Flushes the output stream.
write Writes one or more bytes to the output stream.

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

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

Examples

 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)
  cat(formatC(bfr, width=3))
cat("\n")

close(fin)

# Deletes the temporary file
erase(file)

HenrikBengtsson/R.io documentation built on May 6, 2019, 11:54 p.m.