-
setting filenames in JTable cells
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks