Beruflich Dokumente
Kultur Dokumente
Writer - characters
OutputStream - bytes • OutputStreamWriter
– wraps around OutputStream to get a Writer
• base types – takes characters, converts to bytes
– ByteArrayOutputStream – can specify encoding used to convert
– FileOutputStream – goes to file • CharArrayWriter
– PipedOutputStream – goes to PipedInputStream • StringWriter
• Filters – wrapped around an OutputStream • Filters
– BufferedOutputStream – PrintWriter – supports print, println
– ObjectOutputStream (for serializable objects) – BufferedWriter
• Convenience writers
– wrap OutputStreamWriter around an OutputStream
– FileWriter and PipedWriter
CMCS 433, Spring 2002 - Adam Porter 9 CMCS 433, Spring 2002 - Adam Porter 10
Reader - characters
InputStream - bytes • InputStreamReader
– wrap around InputStream to get a Reader
• base types – takes bytes, converts to characters
– ByteArrayInputStream – can specify encoding used to convert
– FileInputStream
• CharArrayReader
– PipedInputStream
– SocketInputStream (not public) – comes from TCP
• StringReader
socket • Filters
• Filters – wrapped around InputStream – BufferedReader – efficient, supports readLine()
– BufferedInputStream • LineNumberReader – reports line numbers
– PushedBackInputStream – PushBackReader
– ObjectInputStream • Convenience Readers
– wrap InputStreamReader around InputStream
– FileReader and PipedReader
CMCS 433, Spring 2002 - Adam Porter 11 CMCS 433, Spring 2002 - Adam Porter 12
CMCS 433, Spring 2002 - Adam Porter 13 CMCS 433, Spring 2002 - Adam Porter 14
Collection Classes
Other libraries
• interface Collection
– interface List • java.lang.Math
• class Vector (and Stack)
• class ArrayList – abstract final class – only static members
• class LinkedList – doubly linked – includes constants e and π
– interface Set – includes static methods for trig, exponentiation,
• class HashSet
min, max, …
• interface SortedSet
– class TreeSet • java.text
• interface Map – dictionary-like structures – text formatting tools
– class HashMap – replaces HashTable • class MessageFormat provides printf/scanf
– interface SortedMap functionality
• class TreeMap – lots of facilities for internationalization
CMCS 433, Spring 2002 - Adam Porter 17 CMCS 433, Spring 2002 - Adam Porter 18