Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java: Display all PDF files in a directory and subdirectories etc...? I have the

ID: 3752776 • Letter: J

Question

Java: Display all PDF files in a directory and subdirectories etc...?
I have the code that asks the user for a directory, then displays every file in that directory; however, say I want to display only the pdf files in the directory (and all subdirecteries etc..), how would I go about doing that? I'm trying to do this recursively as well. It is not required, but can you leave somewhat of a description of your code whether it be comments or just a description underneath your reply? Will leave a thumbs up!
Here is the code so far:

Explanation / Answer

else if(file.getName().endsWith("pdf")){

Syso(file.getAbsolutePath())

}

Replace else part with

The block like above

U should ist check if file is pdf then only display that

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote