Solved

Reading file names

Posted on 2004-09-01
3
267 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sites similar to codingbat to improve coding hanson skills 3 49
diffSum example 4 36
login jsp example 24 46
arguments to jar 5 26
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now