How do I get a listing of the files in a directory?

John Zukowski

Create a for the directory, then ask for the list of files with one of the following:

public java.lang.String[] list();
public java.lang.String[] list(;
public[] listFiles();
public[] listFiles(;
public[] listFiles(;
The first two return the filenames as strings (for that directory), the latter three return actual File objects.

Also, see Re: how do i search a file from a folder that is in the server side using servlet for another method that lists files in a directory.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact