Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use the listFiles() command

Status
Not open for further replies.

jeremytaffy

Technical User
Sep 6, 2001
75
US
I want to be able to display the files in a certain directory in a JTextArea. I've tried using the
File <directory name> new File(&quot;/directory name&quot;);
and then I used:

<directory name>.listFiles();

This all compiles correctly yet I don't know how to put the information in a Text area. I'd like to have all the files in the directory obtain a certain value in an array if possible.
Thanks.
 
hi,

for implementing listFiles() just create an object of file(passing file path to the constructor ) and then call the listFiles() method on file object.This method returns the array if File

code snippet :

File file=new File(path);
File f[]=file.listFiles();

Indrayani
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top