Summary


Quick File I/O Combination Reference

Don’t sweat the load too much if you still feel somewhat dazed and confused after reading this chapter. The only way you get good at this stuff is through experience. Trust me when I say that you are not alone in your confusion. To help ease your pain and speed your understanding I have included table 18-3 which lists various combinations of the java.io classes based on intended usage.

Table 18-3: Handy java.io Class Combination Reference
Open table as spreadsheet

If you want to

Use the following class or class combination...

Byte-Oriented Stream Output

Write long streams of bytes

FileOutputStream

Write long streams of bytes with improved output efficiency

FileOutputStream BufferedOutputStream

Write streams of bytes and primitive type values

FileOutputStream DataOutputStream

Write streams of bytes and primitive types with improved efficiency

FileOutputStream BufferedOutputStream DataOutputStream

Write serialized objects

FileOutputStream ObjectOutputStream

Write serialized objects with improved efficiency

FileOutputStream BufferedOutputStream ObjectOutputStream

Write textual representations of primitive types and objects

FileOutputStream PrintStream

Write textual representation of primitive types and objects with improved efficiency

FileOutputStream BufferedOutputStream PrintStream

Byte-Oriented Stream Input

Read long streams of bytes

FileInputStream

Read long streams of bytes with improved efficiency

FileInputStream BufferedInputStream

Read serialized objects from disk

FileInputStream ObjectInputStream

Read serialized objects from disk with improved efficiency

FileInputStream BufferedInputStream ObjectInputStream

Character-Oriented Stream Output

Write text to disk in default local encoding

FileWriter

Write text to disk in default local encoding with improved efficiency

FileWriter BufferedWriter

Write characters to disk with more control over character encoding scheme

FileOutputStream OutputStreamWriter

Write characters to disk with more control over character encoding and with improved efficiency

FileOutputStream OutputStreamWriter BufferedWriter

Write textual representations of primitive types and objects with control over character encoding and with improved efficiency

FileOutputStream OutputStreamWriter BufferedOutputStream PrintWriter

Character-Oriented Stream Input

Read text from file in default local encoding

FileReader

Read text from file in default local encoding with improved efficiency

FileReader BufferedReader

Read text from file with more control over character encoding

FileInputStream InputStreamReader

Read text from file with more control over character encoding and with improved efficiency

FileInputStream InputStreamReader BufferedReade

Random Access File Input and Output

Read and write bytes, characters, and primitive type values anywhere within a file

RandomAccessFile




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net