code: public static LocalResource createLocalResourceOfFile(YarnConfiguration yarnConf,
        String resource) throws IOException {
      LocalResource localResource = Records.newRecord(LocalResource.class);
  
      Path resourcePath = new Path(resource);
  
      FileStatus jarStat = FileSystem.get(resourcePath.toUri(), yarnConf).getFileStatus(resourcePath);
      localResource.setResource(ConverterUtils.getYarnUrlFromPath(resourcePath));
      localResource.setSize(jarStat.getLen());
      localResource.setTimestamp(jarStat.getModificationTime());
      localResource.setType(LocalResourceType.FILE);
      localResource.setVisibility(LocalResourceVisibility.PUBLIC);
      return localResource;
    }
docs: Creates a local resource for a file on HDFS.
  
  @param yarnConf YARN configuration
  @param resource the path to a resource file on HDFS
  @return the created local resource