aspose file tools
The moose likes Java in General and the fly likes Check if File is Folder Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Check if File is Folder" Watch "Check if File is Folder" New topic
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
    
    2

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Check if File is Folder
 
Similar Threads
JTree with CheckBox
JTree
JTree
JTree
Need help on JTree