• Post Reply Bookmark Topic Watch Topic
  • New Topic

Check if File is Folder  RSS feed

 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 22697
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The isDirectory() method of the java.io.File class would seem to be a pretty good candidate...
 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh my God,

how could I be so stupid.

Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!