Hi,

I need to read all the files present in a directory and then display all
the names in a JTable object. I coded the method below to list all the files
from a directory, but I dont know how to set each file's name as a cell value
in the JTable..could anyone please help.....



public static String[] listDirectory(String dirName)
{
File entry = new File(dirName);

if (!entry.exists()) {
System.out.println(entry.getName() + " not found.");
return null;
}
if (entry.isFile())
{
System.out.println("listDirectory : This is a file!!");
return (new String[]{entry.getName()});
}
else if (entry.isDirectory())
{
String[] fileNames = entry.list();
return fileNames;
}
System.out.println("listDirectory : No directory found!!");
return null;
}


Regards

Satish