Temporary. Volatile values (stored in variables) are lost when the computer loses its power.
Non-volatile storage
Permanent. A Java program that is saved on a disk uses a non-volatile storage.
Computer file
A collection of data stored on a non-volatile device.
Text file
Consists of data that can be read in a text editor. Data in a text file is encoded using a scheme, such as ASCII and Unicode. Examples are program files and application files.
Binary file
Contains data that is not encoded as text. This file has contents in binary format, which means they cannot be understood by viewing them in a text editor.
Main directory/root directory
Permanent files are stored here.
Folders/directories
Organized stored files.
Path
The complete list of the disk drive plus the hierarchy of directories in which the file is located.
Path delimiter
The backslash (\) used to separate path components.
Path class
Creates objects that contain information about files and directories, such as sizes, locations, creation dates, and is used to check whether a file or directory exists.
Files class
Performs operations on files and directories, such as determining their attributes, creating input and output streams, and deleting them.
A complete path; it does not require any other information to locate a file on a system.
Relative path
Depends on other path information.
String toString()
Returns the String representation of the Path, eliminating double Backslashes.
Path methods
getFileName(), getNameCount(), getName(int)
Path getFileName()
Returns the file or directory denoted by this Path; this is the last item in the sequence of name elements.
int getNameCount()
Returns the number of name elements in the Path.
Path getName(int)
Returns the name in the position of the Path specified by the integer parameter.
toAbsolutePath()
Convert a relative path to an absolute path.
checkAccess()
Verify if a file exists and if a program can access it when needed.
delete()
Method of the Files class accepts a Path parameter and removes the last element (file or directory) in a path or throws an exception if the deletion is unsuccessful.
Exceptionsthrownbydelete()
NoSuchFileException
DirectoryNotEmptyException
SecurityException
IOException
deleteIfExists()
Method can also be used to remove a file without encountering an exception if the file does not exist.