Cp Midterm
Cp Midterm
Debugging Process
Techniques
Exception handling refers to the object-oriented techniques that manage or resolve such errors.
Error Class – represents more serious errors that a program usually might not recover from.
Exception Class – represents less serious errors that indicate unusual conditions that arise while a program is running
and from which the program can recover.
try block This is placed when a programmer creates a segment of code in which something might go wrong.
catch block To handle a thrown exception, one or more catch blocks can be added following a try block.
finally block is used when actions must be performed at the end of a try… catch sequence.
computer file is a collection of data stored on a nonvolatile device or a permanent storage device such as a hard disk,
universal serial bus (USB) drive, compact disk, and reel or cassette of magnetic tape.
Text files contain data that can be read in a text editor as the data is encoded using a scheme (ASCII or Unicode).
data files that contain facts and figures, including a payroll file with employee numbers, names, and salaries.
Binary files contain data items that have not been encoded as text. (0s and 1s)
root directory or main directory of the storage device can be used to store a permanent file.
Path is a complete list of the disk drive and the hierarchy of directories in which a file resides in.
backslash (\) in the Windows operating system is the path identifier which separates the path components.
slash (/) is used as the delimiter in the Solaris (UNIX) operating system.
Path class creates objects containing information about files and directories, including their locations, sizes, creation
dates, and whether they exist.
Files class performs operations on files and directories, including deletion, determining their attributes, and creating
input and output streams.
nio in java.nio stands for new input/output as its classes are “new”
Creating a Path can be initiated by determining the file system on the host computer by using a statement
Paths class is considered a helper class that eliminates the need to create a FileSystem object.
absolute path is a complete path that does not need any information to locate a file on a system.
relative path depends on other path information. For example, a simple path such as SampleFile.txt is relative
String toString() - Returns the String representation of the path, eliminating double backslashes
Path getFileName() - Returns the file or directory denoted by this Path; the last item in the sequence of name elements.
Path getName(int) - Returns the name in the position of the Path specified by the integer parameter
checkAccess() method is used to verify that a file exists and that the program can access it as needed.
No argument – checks that the file exists.
READ – checks that the file exists and the program has permission to read the file
WRITE – checks that the file exists and the program has permission to write to the file
EXECUTE – checks that the file exists and the program has permission to execute the file
readAttributes() method of the Files class can retrieve useful information about a file.
ScreenOut class shows an application declaring a String of letter grades allowed in a course.