Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Get info about directory/file  RSS feed

 
Ayelet Il
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help,
I have a list of directories/files.
When a directory is selected from the list by doubleclicking on it I would like to get a list of the files it contains.
When a file is selected I would like to show it's properties on another list.
How do I do that?...
Thanks
 
Lewin Chan
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try :-
File dir = new File("/home/myhome");
// This gives you a list of the filenames in the directory
File[] fileList = dir.listFiles();
for(int i=0;i<fileList.length;i++){>
printAttributes(fileList[i]);
}
The File class has various methods on it to list the attributes like isDirectory(), isFile(), isHidden(), length() etc etc
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!