77 446
Assignments Done
Successfully Done
In July 2019

Answer to Question #4864 in Java | JSP | JSF for Anthony

Question #4864
Hi there

im trying to check if a directory contains a spesific file extention. example if the directory ( listOfFiles) contains a pdf file.

The problem im having is the checking part. Both my if and else statement execute when the directory contains the file.

If someone can help me with that peace of code please .
Expert's answer
import java.io.File;

// This example searches for .java files in /src/
dir of the project
public class Test {

public static void
main(String[] args) {
String path = "src";
File dir = new
if (dir.isDirectory()) {
File[] listOfFiles =
for (File file : listOfFiles)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions