2016-09-18 91 views
-4

我有一个名为“mail.jar”的jar文件。我通过java代码提取了jar文件。 现在我有清单文件出现在“D:/Test/META-INF/MANIFEST.MF”位置下。 This is the image of Manifest.mf file content。 任何我能够通过FileReaderBufferedReader帮助读取清单文件并将其打印到控制台。 在清单文件中,低于规范r存在。 (1)清单-版本: (2)归档-版本: (3)创建-者: (4)出口型套餐:如何从jar文件中获取Manifest.mf文件内容

现在我的疑问是如何获得下的所有软件包列表出口包装:仅限标签。 任何人都可以帮我吗? 任何帮助将不胜感激。

O/P应显示如下屏幕截图。 Expected O/P screen shot

问候,AD

+0

请更改您的问题。目前还不清楚你想要做什么或需要什么。 –

+0

所罗门,你现在在这里得到我的要求吗?如果有任何疑问,请让我知道如果您有任何疑问... – Abinash

+1

可能与[Manifest](https://docs.oracle.com/javase/7/docs/api/java/util/jar/Manifest .html)类。使用清单文件中的输入流创建一个对象。 – PeterMmm

回答

1

嗨所罗门& PeterMmm, 感谢您的帮助。 现在我可以访问特定属性的清单文件内容。 下面是我使用的代码片段: -

public class ReadmanifestFile { 
public String getManifestAttributes() throws IOException { 
    String value = null; 
    File file = new File("G:/AD/JAR_FILES/mail.jar"); 
    if (file.isFile()) { 
     JarFile jarfile = new JarFile(file); 
     Manifest manifest = jarfile.getManifest(); 
     Attributes attributes = manifest.getMainAttributes(); 
     value = attributes.getValue("Export-Package"); 
     String[] arr = value.split(";"); 
     for (int i = 0; i < arr.length; i++) { 
      System.out.println(arr[i]); 
     } 
    } 
    return value; 
} 

}

点击下面的输出上面的代码片段: - Output

我认为这是do.Plz正道让我知道我是否可以用任何其他方式改进代码片段。

关于, AD