将apk文件中的AndroidManifest.xml转换为可读文本

时间:2014-05-08 06:52:23

标签: java string android-manifest

我正在使用java将Google应用引擎文件上传到Google云端存储。我使用BlobService java API在Google云存储中上传了一个apk文件。并且还可以获取上传的文件。在上传文件进入云存储之前,我需要检查文件是否存在所有文件。那部分也结束了,现在是时候使用AndroidManifest.xml文件了。我已成功读取AndroidManifest.xml文件,但该文件不是纯文本,而是二进制格式。我已经读取了文件,并将文件的所有数据保存为字符串。现在我只想将该字符串变为用户可读格式。是否有任何API使字符串可读?任何帮助将不胜感激。

我读取文件的代码是

BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
InputStream inputStream = new BlobstoreInputStream(blobKeys.get(0));
ZipInputStream zis = new ZipInputStream(inputStream);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null&& entry.getName().endsWith("AndroidManifest.xml")) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    int read = 0;
    while( ( read = zis.read() ) != - 1 ) {
     output.write( read );
    }
    String s=output.toString();  
    System.out.println(s);
    output.close();
     break;
    }
   zis.close();
  inputStream.close();

在上面的代码字符串中包含了不可读格式的AndroidManifest.xml文件数据。

0 个答案:

没有答案