Java讀取ipa中info.plist擷取版本資訊__Java

來源:互聯網
上載者:User
和 Android 的manifest.xml類似,ios中一個應用的版本資訊,應用程式名稱,相容的最低版本等等都在ipa包中的info.plist中列出,但是對於一個打包好ipa包,裡面的info.plist是亂碼的,想要擷取資訊還是相當的麻煩。而最近也要到這方面的需求,找到的第一個方案是使用java調用linux 中的plutil工具來實現對info.plist的解析,這樣做雖然可以實現但感覺太牽強了,,第二個方案是繼續尋找純java的解決方案,找啊找最後還是在老外的一個網站上(overstackflow.com)上找到有人提這樣的問題,幸運的是還有很多哥們回複,老外果然是牛逼,最後照著做,可行了,具體的是找到了一個jar包,簡單調用一下就Ok,先貼一下代碼,對於怎樣從ipa中提取info.plist就不羅嗦了,使用zip流就可以搞定,提供一個別人弄好的實現參考一下就ok( http://code.google.com/p/sunlab/source/detail?r=339 ):

[java] import java.io.File;      import com.dd.plist.PropertyListParser;      public class Plist {       public static void main(String[] args) throws Exception {           File file = new File("d:\\angryInfo.plist");           File file1 = new File("d:\\angryInfo1.plist");                      PropertyListParser.convertToXml(file, file1) ;                                             //InputStream input = Plist.class.getClassLoader().getResourceAsStream("");    //      NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(file);    //          //          //          //          //      String name = rootDict.objectForKey("Name").toString();    //      NSObject[] parameters = ((NSArray) rootDict.objectForKey("Parameters")).getArray();    //      for (NSObject param : parameters) {    //              //          System.out.println(param.toXMLPropertyList());    //              //          if (param.getClass().equals(NSNumber.class)) {    //              NSNumber num = (NSNumber) param;    //              switch (num.type()) {    //              case NSNumber.BOOLEAN: {    //                  boolean bool = num.boolValue();    //                  // ...    //                  break;    //              }    //              case NSNumber.INTEGER: {    //                  long l = num.longValue();    //                  // or int i = num.intValue();    //                  // ...    //                  break;    //              }    //              case NSNumber.REAL: {    //                  double d = num.doubleValue();    //                  // ...    //                  break;    //              }    //              }    //          }    //          // else...    //      }        }   }  

在d盤下找到angryInfo1.plist開啟,已不是亂碼的了,現在想要提取啥資訊就儘管提取。

用到的jar��載:

免費下載地址在 http://linux.linuxidc.com/

使用者名稱與密碼都是www.linuxidc.com

具體下載目錄在 /2012年資料/1月/14日/Java讀取ipa中info.plist擷取版本資訊/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.