Monday, March 14, 2011

Byte Stream vs Character Stream

Byte Stream Class:
  • Byte Stream are defined by two hierarchies 
    1. InputStream
    2. OutputStream
  •  The abstract class InputStream and OutputStream define several key method that the other stream classes implement. The two most Important are
    1. read()
    2. write()
  • Stream class (Subclass)
    • BufferedInputStream
    • BufferedOutputStream
    • ByteArrayInputStream
    • ByteArrayOutputStream
    • DataInputStream
    • DataOutputStream
    • FileInputStream
    • FileOutputStream
    • PrintStream
    • PushbackInputStream
Character Stream class:
  • Character stream are defined by two class hierarchies
    1. Reader
    2. Writer
  • These class handle unicode character stream.
  • The most important method are
    1. read()
    2. write()  which read/write the character of data.
  • character classes
    • BufferedReader
    • BufferedWriter
    • CharArrayReader
    • CharArrayWriter
    • InputStreamReader
    • OutputStreamReader
    • FileReader
    • FileWriter
    • PrintWriter
    • PushbackReader
 Streams - Byte Based(Read or write Bytes)[Mainly used for Binary files)
Reader - Character Based(Read or Write Character)[for Text files]

 Filereader is the best option as it reads the file characterwise or u can use bufferedreader because it reads stringwise. 

No comments: