Directory tree model for JavaFX that watches the filesystem for changes.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


LiveDirsFX is a combination of a directory watcher, a directory-tree model (for TreeView) and a simple asynchronous file I/O facility. The extra benefits of this combination are:

  1. Automatic synchronization of the directory model with the filesystem.
  2. Ability to distinguish directory and file modifications made by the application (through the I/O facility) from external modifications.


enum ChangeSource {
    INTERNAL, // indicates a change made by this application
    EXTERNAL, // indicates an external change

// create LiveDirs to watch a directory
LiveDirs<ChangeSource> liveDirs = new LiveDirs<>(EXTERNAL);
Path dir = Paths.get("/path/to/watched/directory/");

// use LiveDirs as a TreeView model
TreeView<Path> treeView = new TreeView<>(liveDirs.model().getRoot());

// handle external changes
liveDirs.model().modifications().subscribe(m -> {
    if(m.getInitiator() == EXTERNAL) {
        // handle external modification, e.g. reload the modified file
    } else {
        // modification done by this application, no extra action needed

// Use LiveDirs's I/O facility to write to the filesystem,
// in order to be able to distinguish between internal and external changes.
Path file = dir.resolve("some/file.txt");, "Hello text file!", INTERNAL);

// clean up

Use LiveDirsFX in your project

Method 1: as a managed dependency (recommended)

Snapshot releases are deployed to Sonatype snapshot repository with these Maven coordinates

Group ID Artifact ID Version
org.fxmisc.livedirs livedirsfx 1.0.0-SNAPSHOT

Gradle example

repositories {
    maven {
        url '' 

dependencies {
    compile group: 'org.fxmisc.livedirs', name: 'livedirsfx', version: '1.0.0-SNAPSHOT'

Sbt example

resolvers += "Sonatype OSS Snapshots" at ""

libraryDependencies += "org.fxmisc.livedirs" % "livedirsfx" % "1.0.0-SNAPSHOT"

Method 2: as an unmanaged dependency

Download the latest JAR or fat JAR (including dependencies) and place it on your classpath.