Intro to I/O in Java
Terms
- stream
- A source for input or a destination for output.
- whitespace
- Refers to the space, tab, and newline characters.
- delimiter
- Any character that is used to separate individual tokens.
- token
- A portion of a string defined by a set of delimiters.
- absolute pathname
- The directory path to a file location that begins with the root of
the directory in which the file is located.
- relative pathname
- The directory path to a file location that begins with the current
working directory.
- checked exception
- An exception that must be handled or thrown in a program. I/O errors
are checked exceptions.
- unchecked exception
- An exception that may be ignored in a program. Descendents of the
RuntimeException are the only unchecked exceptions in java.
Classes you should know
- Scanner
- Specifically, its use related to input and tokenizing a String.
- File
- The class to specify file names for both input and output.
- PrintWriter
- The class used to print to files.
- StringTokenizer
- A class that can be used to tokenize String objects.
Today's notes
Review solution to Wednesday lab
I/O Basics
- Streams
- Java classes that we have used
- Scanner - System.in
- PrintStream - System.out
- File processing - new classes
- File
- PrintWriter
- Absolute vs relative path names
- IO.java
- Exceptions that occur with file processing
- Checked vs unchecked exceptions
- Java treats RuntimeException descendents as unchecked
Scanner uses
- Input from the keyboard (System.in)
- Input from File objects
- Be aware that Scanner ignores newline characters.
- Manipulating String object data
String tokenizer - an introduction
More information about the File class
CS 239 - Spring 2006