Java 如何读取AndroidManifest.xml(二进制)文件?
我试图读取AndroidManifest.xml文件的内容,该文件似乎是“DBase 3数据文件”二进制格式Java 如何读取AndroidManifest.xml(二进制)文件?,java,android,Java,Android,我试图读取AndroidManifest.xml文件的内容,该文件似乎是“DBase 3数据文件”二进制格式 Java中有没有关于如何读取这个二进制文件的代码示例?我不需要写,只需阅读文本内容。步骤1:首先需要使用apktool提取.apk文件 步骤2:现在我们想使用Java DOM xml解析器读取androidmanifest.xml文件 例如,要从androidmanifest.xml读取“uses permission”标记吗 public class parse_xml {
Java中有没有关于如何读取这个二进制文件的代码示例?我不需要写,只需阅读文本内容。步骤1:首先需要使用apktool提取.apk文件 步骤2:现在我们想使用Java DOM xml解析器读取androidmanifest.xml文件 例如,要从androidmanifest.xml读取“uses permission”标记吗
public class parse_xml
{
public static void main(String argv[])
{
try {
File fXmlFile= new File("C:\\apkfolder\\AndroidManifest.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
System.out.println("Root element :"+ doc.getDocumentElement().getNodeName());
NodeList nList= doc.getElementsByTagName("uses-permission");
System.out.println("----------------------------");
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
//System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
System.out.println(eElement.getAttribute("android:name"));
}
}
System.out.println("total no. of permissions"+ nList.getLength());
} catch (Exception e) {
}
}
}
公共类解析xml
{
公共静态void main(字符串argv[])
{
试一试{
文件fXmlFile=新文件(“C:\\APKFOLD\\AndroidManifest.xml”);
DocumentBuilderFactory dbFactory=DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder=dbFactory.newDocumentBuilder();
documentdoc=dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
System.out.println(“根元素:+doc.getDocumentElement().getNodeName());
NodeList nList=doc.getElementsByTagName(“使用权限”);
System.out.println(“-------------------------------”;
对于(int-temp=0;temp