code: public static boolean canReadAndWriteFile (@Nullable final File aFile)
    {
      if (aFile == null)
        return false;
  
      if (aFile.exists ())
      {
        // File exists
        if (!aFile.canRead () || !aFile.canWrite ())
          return false;
      }
      else
      {
        // Path does not exist (yet)
        // Check parent directory
        final File aParentFile = aFile.getAbsoluteFile ().getParentFile ();
        if (aParentFile == null || !aParentFile.isDirectory () || !aParentFile.canRead () || !aParentFile.canWrite ())
          return false;
      }
      return true;
    }
docs: Check if the passed file can read and write. If the file already exists,
  the file itself is checked. If the file does not exist, the parent
  directory
  
  @param aFile
  The file to be checked. May be <code>null</code>.
  @return <code>true</code> if the file can be read and written