Solved

Reading file names

Posted on 2004-09-01
3
278 Views
Last Modified: 2010-03-31
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
Comment
Question by:Programmer_to_be
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 25 total points
ID: 11956709
0
 
LVL 35

Expert Comment

by:girionis
ID: 11956731
0
 
LVL 18

Assisted Solution

by:bobbit31
bobbit31 earned 25 total points
ID: 11956756
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 17 59
Java string replace 11 62
Java syntax, or is it Selenium 6 39
Java class and jar 3 42
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question