code: private void checkOutputFile(File file) throws ApkCreationException {
          if (file.isDirectory()) {
              throw new ApkCreationException("%s is a directory!", file);
          }
  
          if (file.exists()) { // will be a file in this case.
              if (!file.canWrite()) {
                  throw new ApkCreationException("Cannot write %s", file);
              }
          } else {
              try {
                  if (!file.createNewFile()) {
                      throw new ApkCreationException("Failed to create %s", file);
                  }
              } catch (IOException e) {
                  throw new ApkCreationException(
                          "Failed to create '%1$ss': %2$s", file, e.getMessage());
              }
          }
      }
docs: Checks an output {@link File} object.
  This checks the following:
  - the file is not an existing directory.
  - if the file exists, that it can be modified.
  - if it doesn't exists, that a new file can be created.
  @param file the File to check
  @throws ApkCreationException If the check fails