Basic HTML version of Foils prepared 18 May 97

Foil 27 FilterInputStreams

From Java Tutorial - Spring 1997 Part 4: Multithreading, useful Java classes, I/O, Networking, and the future Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


1 There is a clever class called FilterInputStream which can be used to add value to a raw InputStream. You can define your own filters but important ones provided are:
  • BufferedInputStream -- establishs an intermediate buffer to service stream
  • DataInputStream -- allows one to address stream in terms of higher level constructs -- namely read a line, read a long integer etc.
  • LineNumberInputStream -- adds line numbers to a stream
  • PushbackInputStream -- allows one to "unread" a character and put it back on the input stream
2 These streams can be constructed from each other or InputStream to give added functionality. If "is" is an InputStream, then it can be converted to a buffered input stream with methods from datainputstream:
3 DataInputStream data = new DataInputStream(new BufferedInputSream(is));

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Thu Jan 8 1998