FileLock (@NotNull Path directory) { try { Files.createDirectories(directory); Path lockFile = directory.resolve(LOCK_FILE_NAME); //noinspection resource FileChannel fc = FileChannel.open(lockFile, StandardOpenOption.CREATE, StandardOpenOption.APPEND, StandardOpenOption.WRITE); return fc.tryLock(); } catch (IOException ignore) { return null; } }