Return the version string metadata value for the plugin file, or null if it is not available or could not
loaded
@param file file
@return version string
970724
static String getVersionForFile(final File file)  {
        try {
            final PluginMeta pluginMeta = loadMeta(file);
            return pluginMeta.getVersion();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
1202480
public static String getContentType(@Nonnull File file) throws IOException {
        if (file == null) {
            throw new IllegalArgumentException("A file must be specified.");
        } else if (!file.exists()) {
            throw new IllegalArgumentException(file.getCanonicalPath() + " does not exist.");
        } else if (!file.isFile()) {
            throw new IllegalArgumentException(file.getCanonicalPath() + " is not a file.");
        }

        String contentType = URLConnection.guessContentTypeFromName(file.getName());
        if (contentType == null || !contentType.startsWith("image/")) {
            throw new IllegalArgumentException(file.getCanonicalPath() + " is not a supported image file.");
        }

        return contentType;
    }
606952
public static String getApplicationVersionFromJar(Class<?> _class, String _default) {
        try {
            Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF");
            while (resources.hasMoreElements()) {

                Manifest manifest = new Manifest(resources.nextElement().openStream());
                Attributes attribs = manifest.getMainAttributes();
                String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
                if (ver == null) {
                	return _default;
                }

                String rev = attribs.getValue("Implementation-Revision");
                if (rev != null) {
                    ver += "-r" + rev;
                }
                return ver;

            }
        } catch (IOException _ex) {
        }

        return _default;
    }
210823
private static String parseFilePath(String file)
    {
        final String excludePattern = "/META-INF/persistence.xml";
        file = file.substring(0, file.length() - excludePattern.length());

        // in case protocol is "file".
        file = file.endsWith("!") ? file.substring(0, file.length() - 1) : file;

        return file;
    }
553023
protected String getVersion(JSONObject json, String fileName) {
        if (json.has(Constants.VERSION)) {
            return json.getString(Constants.VERSION);
        }
        logger.debug("version not found in file {}", fileName);
        return Constants.EMPTY_STRING;
    }
838833
public static String readFileFromClasspath(String file) {
		logger.trace("Reading file [{}]...", file);
		String content = null;

		try (InputStream asStream = SettingsReader.class.getClassLoader().getResourceAsStream(file)) {
			if (asStream == null) {
				logger.trace("Can not find [{}] in class loader.", file);
				return null;
			}
			content = IOUtils.toString(asStream, "UTF-8");
		} catch (IOException e) {
			logger.warn("Can not read [{}].", file);
		}

		return content;
	}
494946
public function version($file)
    {
        try {
            $manifest = $this->readManifestFile();
        } catch (\Exception $e) {
            Craft::log(printf($e->getMessage()), LogLevel::Info, true);
            return $file;
        }

        // if no manifest, return the regular asset
        if (!$manifest) {
            return $file;
        }

        return '/' . $this->buildPath . '/' . $manifest[$file];
    }
225077
public static String getVersionInfo() {
        String info = versionInfo.get();
        if (info == null) {
            info = String.format(Locale.ENGLISH, VERSION_INFO, getLibInfo(), getSysInfo());

            versionInfo.compareAndSet(null, info);
        }

        return info;
    }
1129642
def getPluginVersion():
    """"""
    desc_file = os.path.join('cdmplugins', 'gc', plugin_desc_file)
    if not os.path.exists(desc_file):
        print('Cannot find the plugin description file. Expected here: ' +
              desc_file, file=sys.stderr)
        sys.exit(1)

    with open(desc_file) as dec_file:
        for line in dec_file:
            line = line.strip()
            if line.startswith('Version'):
                return line.split('=')[1].strip()
    print('Cannot find a version line in the ' + desc_file,
          file=sys.stderr)
    sys.exit(1)
1221700
public String getResourceType(CmsFileInfo file) {

        String typeName = null;
        typeName = getExtensionMapping().get(file.getFileSuffix().toLowerCase());
        if (typeName == null) {
            typeName = "plain";
        }
        return typeName;
    }
44974
public static String getFileMimeType(final File file) {
		if (file != null) {
			try {
				final Tika tika = new Tika();
				return tika.detect(file.getInputStream());
			} catch (IOException ex) {
				LOG.error("Invalid file, name " + file.getName(), ex);
			}
		}
		return null;
	}
1327881
function ( version, options ){
			
		var matches;
		
		//First if version is 'readme' or 'plugin' version values
		if( version === 'readme' ){
			var readme = grunt.file.read( options.readme );
			matches = readme.match( new RegExp("^Stable tag:\\s*(\\S+)","im") );
			
			if( matches.length <= 1 ){
				grunt.fail.fatal( 'Could not find version in "' + options.readme + '"' );
			}
			version = matches[1];
		
		}else if( version === 'plugin' ){
			var plugin = grunt.file.read( options.plugin );
			matches = plugin.match( new RegExp("^[\* ]*Version:\\s*(\\S+)","im") );
			if( matches.length <= 1 ){
				grunt.fail.fatal( 'Could not find version in "' + options.readme + '"' );
			}
			version = matches[1];
		}
		
		return version;
	}
860280
private static String getVersion() {
    final String defaultVersion = "dev-" + System.currentTimeMillis();
    final String fileName = "bigtable-version.properties";
    final String versionProperty = "bigtable.version";
    try (InputStream stream =
        BigtableVersionInfo.class.getResourceAsStream(fileName)) {
      if (stream == null) {
        LOG.error("Could not load properties file bigtable-version.properties");
        return defaultVersion;
      }

      Properties properties = new Properties();
      properties.load(stream);
      String value = properties.getProperty(versionProperty);
      if (value == null) {
        LOG.error("%s not found in %s.", versionProperty, fileName);
      } else if (value.startsWith("$")){
        LOG.info("%s property is not replaced.", versionProperty);
      } else {
        return value;
      }
    } catch (IOException e) {
      LOG.error("Error while trying to get user agent name from %s", e, fileName);
    }
    return defaultVersion;
  }
271073
public static String getExtension(String file)
    {
        Check.notNull(file);

        String ext = Constant.EMPTY_STRING;
        final int i = file.lastIndexOf(Constant.DOT);
        if (i >= 0 && i < file.length() - 1)
        {
            ext = file.substring(i + 1).toLowerCase(Locale.ENGLISH);
        }
        return ext;
    }
915779
public static String fileAsString(File file) {
    try {
      return inputStreamAsString(new FileInputStream(file));
    } catch(FileNotFoundException e) {
      throw LOG.fileNotFoundException(file.getAbsolutePath(), e);
    }
  }
516968
public static String getFormatVersion(File filename) {
		final ContentFileTypeMap map = ensureContentTypeManager();
		return map.getFormatVersion(filename);
	}
1057354
public static String getVersion() {
        String version = null;

        // try to load from maven properties first
        try {
            Properties p = new Properties();
            InputStream is = VersionHelper.class.getResourceAsStream("/META-INF/maven/io.redlink/redlink-sdk-java/pom.properties");
            if (is != null) {
                p.load(is);
                version = p.getProperty("version", "");
            }
        } catch (Exception e) {
            // ignore
        }

        // fallback to using Java API
        if (version == null) {
            Package aPackage = VersionHelper.class.getPackage();
            if (aPackage != null) {
                version = aPackage.getImplementationVersion();
                if (version == null) {
                    version = aPackage.getSpecificationVersion();
                }
            }
        }

        // fallback to read pom.xml on testing
        if (version == null) {
            final MavenXpp3Reader reader = new MavenXpp3Reader();
            try {
                Model model = reader.read(new FileReader(new File("pom.xml")));
                version = model.getVersion();
            } catch (IOException | XmlPullParserException e) {
                // ignore
            }
        }

        return version;
    }