February 2014
Beginner
1248 pages
62h 25m
English
Figure 15.2 prompts the user to enter a file or directory name, then uses classes Paths, Path, Files and DirectoryStream to output information about that file or directory. The program begins by prompting the user for a file or directory (line 16). Line 19 inputs the filename or directory name and passes it to Paths static method get, which converts the String to a Path. Line 21 invokes Files static method exists, which receives a Path and determines whether it exists (either as a file or as a directory) on disk. If the name does not exist, control proceeds to line 49, which displays a message containing the Path’s String representation followed by “does not exist.” Otherwise, lines 24–45 execute: ...
Read now
Unlock full access