java.util.jar.Manifest.equals()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中java.util.jar.Manifest.equals()方法的一些代码示例,展示了Manifest.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Manifest.equals()方法的具体详情如下:
包路径:java.util.jar.Manifest
类名称:Manifest
方法名:equals

Manifest.equals介绍

[英]Determines if the receiver is equal to the parameter object. Two Manifests are equal if they have identical main attributes as well as identical entry attributes.
[中]确定接收器是否等于参数对象。如果两个清单具有相同的主属性以及相同的条目属性,则它们是相等的。

代码示例

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

  1. @Override
  2. public final boolean equals(final Object o) {
  3. if (o instanceof JogampVersion) {
  4. return mf.equals(((JogampVersion) o).getManifest());
  5. }
  6. return false;
  7. }

代码示例来源:origin: tterrag1098/BON2

  1. @Override
  2. public boolean equals(Object o) {
  3. if(this == o) {
  4. return true;
  5. }
  6. if(o == null || getClass() != o.getClass()) {
  7. return false;
  8. }
  9. ClassCollection that = (ClassCollection)o;
  10. if(classes != null ? !classes.equals(that.classes) : that.classes != null) {
  11. return false;
  12. }
  13. if(extraFiles != null ? !extraFiles.equals(that.extraFiles) : that.extraFiles != null) {
  14. return false;
  15. }
  16. if(manifest != null ? !manifest.equals(that.manifest) : that.manifest != null) {
  17. return false;
  18. }
  19. return true;
  20. }

代码示例来源:origin: stackoverflow.com

  1. public static void main(String[] args) {
  2. JarFile jar = null;
  3. try {
  4. jar = new JarFile("plugin.jar");
  5. } catch (IOException e) {
  6. e.printStackTrace();
  7. }
  8. ZipFile zipFile = null;
  9. try {
  10. zipFile = new ZipFile("plugin.jar");
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. final ZipEntry manifestEntry = zipFile.getEntry("META-INF/MANIFEST.MF");
  15. Manifest smActual = null;
  16. Manifest smExpected = null;
  17. try {
  18. smActual = new Manifest(jar.getInputStream(manifestEntry));
  19. smExpected = new Manifest(new FileInputStream("META-INF/MANIFEST.MF"));
  20. } catch (IOException e) {
  21. e.printStackTrace();
  22. }
  23. if(smActual.equals(smExpected)) {
  24. System.out.println("Yes Equal");
  25. } else {
  26. System.out.println("They are not equal");
  27. }
  28. }

相关文章