How do I get a listing of the files in a directory?
Created May 4, 2012
John Zukowski Create a java.io.File 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(java.io.FilenameFilter); public java.io.File[] listFiles(); public java.io.File[] listFiles(java.io.FilenameFilter); public java.io.File[] listFiles(java.io.FileFilter);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.