Question: Question 3 - Security permission Develop a program that lists the files and subdirectories in a directory, using a security manager and an associated security

 Question 3 - Security permission Develop a program that lists the

Question 3 - Security permission Develop a program that lists the files and subdirectories in a directory, using a security manager and an associated security policy file. The program, called ListFiles, programmatically sets the policy file (which is in the working directory), installs a security manager, obtains and displays the files and subdirectories in a directory. The directory is specified as a command-line argument to the program. If there is any exception, the program should display the exception message and end its execution. (Hint: To obtain the files and subdirectories in a directory, you may use the list method of the File class.) The security policy file, called ListFiles.policy, grants read access to the directory C:\Program Files\Java and all its subdirectories (recursively). Submit both the program and the policy file. These are sample outputs of running the program > java ListFiles C:\Program Files\Java jdk-14.0.1 jdk1.8.0_77 jre1.8.0_77 jre7 > java ListFiles C:\Program Files\Java\jdk-14.0.1 bin conf COPYRIGHT include jmods legal lib release > java ListFiles C:\ Exception: access denied ("java.io.FilePermission" "C:\" "read") > java ListFiles C:\Windows Exception: denied ("java.io.FilePermission" "C:\Windows" "read") access

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!