Java Path File Name nio getManifestProperty(Path pathToJar, String propertyName)

Here you can find the source of getManifestProperty(Path pathToJar, String propertyName)

Description

get Manifest Property

License

Open Source License

Declaration

public static String getManifestProperty(Path pathToJar,
            String propertyName) throws IOException 

Method Source Code

//package com.java2s;
/**//from w  ww  .  ja  va 2s . com
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.File;

import java.io.IOException;

import java.nio.file.Path;

import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

public class Main {
    public static String getManifestProperty(Path pathToJar,
            String propertyName) throws IOException {
        File file = pathToJar.toFile();

        try (JarFile jar = new JarFile(file)) {
            Manifest manifest = jar.getManifest();

            Attributes attributes = manifest.getMainAttributes();

            return attributes.getValue("Bundle-Version");
        }
    }
}

Related

  1. getFullPath(String basePath, String fileName)
  2. getIndexPath(String rootDirectory, String basename)
  3. getJarContainingClass(String path, String className)
  4. getLatestUpgradeScriptName(Path upgradeScriptsDir)
  5. getLocalFilePath(String localDirectory, String filename)
  6. getName(Path file)
  7. getName(Path path)
  8. getName(Path path)
  9. getName(Path path)