• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scan a directory and return a list of files based on extension  RSS feed

 
Matt Wallace
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a program that scans a directory and creates a list of file paths for only the files with a ".PAT" extensions. This is what I have so far:



However, the iterative section returns a sequential list of file paths, repeating the results of each read through the directory.

I simply want to generate a list of file paths.
 
Paweł Baczyński
Bartender
Posts: 2076
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Take a look at this tutorial.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your second for loop supposed to be inside the first? The indentation suggests not, but you don't actually close the first one.
 
Matt Wallace
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct, I meant to close it. In revisiting the problem, I was able to fix it!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!