Write a program that will read detailed information about a folder and display it on the console. First of all, read the folder path from the console. If the entered path is not a directory, display "[full path] is not a folder" and exit the program.
What's in the folder?
You must be signed in to leave a comment
10 May 2021, 12:36
Misleading Conditions again. You CAN use classes/methods which aren't from java.nio package - e.g. for console Input. "exit the program" via an if-statement with void return. Don't count the starting folder.
5 August 2022, 01:24
I think the class restriction is mostly checking to make sure that you aren't using the File class, i.e. creating File objects. They want you to do this using the Files utility methods instead. But yes, it's misleading. You don't even need to use a void return. I just tested for Files.isDirectory and then in the else you have the line to print. You don't have to do anything else, if will just complete the execution of the main method and end normally. The easiest way to "not count" the starting folder is to be aware that the process will count it, and then just -- the counting variable at the end.
24 July 2020, 17:46
FYI, don't use System.exit() to end the program if the path isn't a directory. It will mess with the verification system if you do.