public static long getByteSize(final Path dir) {
        final AtomicLong total = new AtomicLong();
        try {
            try (final Stream<Path> stream = Files.walk(dir)) {
                stream.forEach(path -> {
                    try {
                        if (Files.isRegularFile(path)) {
                            total.addAndGet(Files.size(path));
                        }
                    } catch (final IOException e) {
                        LOGGER.debug(e::getMessage, e);
                    }
                });
            }
        } catch (final IOException e) {
            LOGGER.debug(e::getMessage, e);
        }
        return total.get();
    }
Obtains a write lock on lockFilePath then runs the work. Creates lockFilePath
if it doesn't exist. Will block if another thread/jvm holds a lock on the same
file.
stroom-util/src/main/java/stroom/util/io/FileUtil.java