private static String isWritable(Path path) {
    if (!Files.isReadable(path)) {
      return "not readable";
    }
    if (!Files.isWritable(path)) {
      return "not writable";
    }
    try (FileChannel ch = FileChannel.open(path, StandardOpenOption.WRITE, StandardOpenOption.APPEND); FileLock lock = ch.tryLock()) {
      if (lock == null) {
        return "locked by another process";
      }
    }
    catch (OverlappingFileLockException | IOException e) {
      LOG.log(Level.WARNING, path.toString(), e);
      return "cannot lock: " + e.getMessage();
    }
    return null;
  }
private static String isWritable(Path path)