code: public static boolean isDirWritable(final File dir) {
      File testFile = null;
      try {
        testFile = new File(dir, "_tmp");
        /*
         * Create and delete a dummy file in order to check file permissions. Maybe
         * there is a safer way for this check.
         */
        testFile.createNewFile();
      } catch (final IOException e) {
        return false;
      } finally {
        if (testFile != null) {
          testFile.delete();
        }
      }
      return true;
    }
docs: Check if a directory is writable
  
  @param dir directory file object
  @return true if it is writable. false, otherwise