[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

Reading file names

Hi,

How can I read the names of many files under one directory? I have about 30 *.doc files in a directory and would like to read the names of the files into my program.

Any tips/hints/code snippets would be greatly appreciated.
0
Programmer_to_be
Asked:
Programmer_to_be
  • 2
2 Solutions
 
girionisCommented:
0
 
bobbit31Commented:
File f = new File("<path to dir>");

if (f.exists() && f.isDirectory()) {
   File[] files = file.listFiles();
   for (int i=0; i<files.length; i++)
   {
      System.out.println(files[i].getName());
   }
}
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now