code: private static FileResource getFileResourceProto(final String fileName, final FileType type) throws IOException {
      File file = new File(fileName);
      if (file.exists()) {
        // It is a local file and can be added.
        if (file.isDirectory()) {
          // If it is a directory, create a JAR file of it and add that instead.
          file = toJar(file);
        }
        return FileResourceImpl.newBuilder()
            .setName(file.getName())
            .setPath(file.getPath())
            .setType(type)
            .build();
      } else {
        // The file isn't in the local filesytem. Assume that the file is actually a URI.
        // We then assume that the underlying resource manager knows how to deal with it.
        try {
          final URI uri = new URI(fileName);
          final String path = uri.getPath();
          final String name = path.substring(path.lastIndexOf('/') + 1);
          return FileResourceImpl.newBuilder()
              .setName(name)
              .setPath(uri.toString())
              .setType(type)
              .build();
        } catch (final URISyntaxException e) {
          throw new IOException("Unable to parse URI.", e);
        }
      }
    }
docs: Turns a pathname into the right protocol for job submission.
  
  @param fileName
  @param type
  @return
  @throws IOException