Java IO frameworks - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Java IO frameworks

Description:

Decorating functions are: Reading/writing primitive (int, char, float... Many take streams as decorated objects. Similar basic operations Reader and Writer ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 9
Provided by: csBg
Category:

less

Transcript and Presenter's Notes

Title: Java IO frameworks


1
Java I/O frameworks
  • Input and output

2
Java I/O overview
  • 3 different frameworks
  • Streams (Java 1.0)
  • Readers and writers (Java 1.2)
  • NIO New I/O (java 1.4)
  • Some bridging between frameworks for backward
    compatibility
  • Main concept decorators (wrappers)
  • Followed through most of the frameworks

3
Decorators
  • Basic idea
  • All classes implement the same basic
    functionality
  • Concrete suppliers actually do something
  • Decorators take instance of that interface as
    constructor parameter, and wrap it with extra
    functionality (decorate)

Each decoratortakes the previousone, use it,
and extends its functionality
Source
4
Decorators class diagram
BaseFuncfunc()
Decorated object
Sourcefunc()
Decoratorfunc()
Actually do something
Use the decorated objectto do some more
5
I/O decorators
  • Basic function is reading or writing byte arrays
  • Sources are actual I/O devices or sources, like
  • Files
  • Sockets
  • Byte arrays
  • Pipes
  • Strings
  • Decorating functions are
  • Reading/writing primitive (int, char, float)
  • Reading/writing objects
  • Compressing / decompressing
  • Buffering
  • Reading lines of text
  • Printing
  • Writing lines
  • Filtering

6
Java steams
  • The original Java I/O framework
  • Located at the java.io package
  • Basic operations are reading or writing ints and
    byte arrays InputStream and OutputStream
    abstract classes
  • Sources/targets are mainly files, sockets, etc.
  • Decorators include object handling, filtering,
    compression, (some) buffering, etc.
  • Deprecated replaced with readers/writers

7
Java readers/writers
  • Javas replacement for old streams
  • But also at the same package
  • There are bridging classes InputStreamReader and
    OutputStreamWriter
  • Many take streams as decorated objects
  • Similar basic operations Reader and Writer
  • Similar sources/targets files, sockets
  • Similar decorators buffering, filtering,
    strings
  • Slightly added and improved functionality

8
Java New I/O - NIO
  • New, innovative I/O framework
  • Located at its own package java.nio
  • Caused changes throughout the entire library
  • Based on buffers and channels
  • Like streams, but read in big chunks
  • Used mainly for large-scale operations, like
  • File mapping to memory
  • Text charset decoding regular-expressions parsing
  • Channels gathering and scattering

Neo
Write a Comment
User Comments (0)
About PowerShow.com