Code examples used for this class were from “Java How to
Program” Ch. 14
Recommended Study Action:
Review the
Self review exercises of Ch 14
Read all
exercises of Ch. 14 and formulate ideas as to how these problems would be
completed.
Try
to implement 14.13
*********************************************************************
File Class
Can use absolute or relative paths.
File.pathSeparator retrieves a systems path separator constant.
Directories are files.
Stream - Ordered Data read from or written to a file
Abstract Classes: InputStream, OutputStream
Provide simple implementations of read and write methods.
(http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html)
(http://java.sun.com/j2se/1.4.2/docs/api/java/io/OutputStream.html)
Binary vs Character Based Files
Binary files are not Human readable
Binary files are read and written equally in all java JVMs
Character Based Files are Human readable
Character Based Files use system specific Character Sets
System.in, System.out, System.err
System.in is an InputStream Object
System.out is a PrintStream Object
System.err is a PrintStream Object
Text File Processing
Reads System Specific Charset characters in and converts to Unicode Charset
Format defined by programmer, including field delimiters
Object Serialization
Implements Serializable
Can only serialize objects that are primitive or Searializable!
Keyword ‘transient’ tells the compiler not to store this variable
RandomAccessFiles
Pointer can be moved to any postion within the file
Records of fixed length can be easily accessed
No More Field Delimiters!