| Author |
Check if File is Folder
|
Mathew Mintalm
Ranch Hand
Joined: Feb 21, 2010
Posts: 102
|
|
Hello, im making my own JTree, that reads files from system
And i have strange issue, if folder is empty its icon is like normal file (displaying at JTree)
So I guess i will have to check if file.. is folder?
What have i tryed so far? Checking file extension, thought that if extension doesnt exist it may means that its folder, bur doesnt work:
String patch = selectedNode.getAbsolutePath();
int dotPos = patch.lastIndexOf(".");
String extension = patch.substring(dotPos);
System.out.println("File Extension: " + extension);
Any solutions?
Thanks in advance!
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
|
The isDirectory() method of the java.io.File class would seem to be a pretty good candidate...
|
 |
Mathew Mintalm
Ranch Hand
Joined: Feb 21, 2010
Posts: 102
|
|
Oh my God,
how could I be so stupid.
Thank you.
|
 |
 |
|
|
subject: Check if File is Folder
|
|
|