Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

javafx treeview directory

TreeView<String> a = new TreeView<String>();
a.setRoot(getNodesForDirectory(new File("C:")));

public TreeItem<String> getNodesForDirectory(File directory) { //Returns a TreeItem representation of the specified directory
    TreeItem<String> root = new TreeItem<String>(directory.getName());
    for(File f : directory.listFiles()) {
        System.out.println("Loading " + f.getName());
        if(f.isDirectory()) { //Then we call the function recursively
            root.getChildren().add(getNodesForDirectory(f));
        } else {
            root.getChildren().add(new TreeItem<String>(f.getName()));
        }
    }
    return root;
}
Comment

PREVIOUS NEXT
Code Example
Java :: add days to a date java 
Java :: print max activity by greedy technique in java 
Java :: Program to check Vowel or Consonant using Switch Case 
Java :: return index using matcher java 
Java :: play default message ringtone android studio 
Java :: how to uncomment a block of statements in java 
Java :: recycler view event being raised multiple times 
Java :: problem solving using recursion in java 
Java :: java :: operator 
Java :: how to find last element in array java 
Java :: && java 
Java :: is java pass by value or pass by reference 
Java :: Jlabel icon 
Java :: multiple return values in function java 
Java :: java remove map key 
Java :: java final class 
Java :: java float precision 
Java :: java format double no decimal places 
Java :: javafx load image from resources 
Java :: local inner class in java 
Java :: java dato numero big starkoverflow 
Sql :: safe mode off mysql 
Sql :: postgres get running query 
Sql :: how to truncate table with foreign key constraint 
Sql :: Enter into postgresql database,create user and grant Access 
Sql :: get tables in database sql 
Sql :: search stored procedures 
Sql :: update password postgres user 
Sql :: oracle apex version view 
Sql :: python sqlite3 create table if not exists 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =