下面是需要用流去读的xml文件:
Xml代码
<?xml version="1.0" encoding="UTF-8"?>
<page pageId ="deskTop" pageTitle="我的桌面" pageVersion="1.0" cache="Check">
<body bgImage="$bgImage$">
<gridTable nameId="gid1" location="" size="" rows="3" cols="3">
<gridItem text="移动产品" url="$server_path$/Api.ashx?function=getGrpProduct&id_u=$id_u$" img="local://resources/desktop/2.png"/>
<gridItem text="集团产品" url="$server_path$/Api.ashx?function=getProduct&id_u=$id_u$" img="local://resources/desktop/3.png"/>
<gridItem text="知识库" url="$server_path$/Api.ashx?function=getKnowledgeTypes&id_u=$id_u$" img="local://resources/desktop/0.png"/>
<gridItem text="信息采集" url="$server_path$/Api.ashx?function=getCollType&id_u=$id_u$" img="local://resources/desktop/1.png"/>
<gridItem text="在线交流" url="$server_path$/Api.ashx?function=getMyQuestionList&id_u=$id_u$&id_acc=$id_acc$" img="local://resources/desktop/4.png"/>
<gridItem text="通讯录" url="$server_path$/Api.ashx?function=getAddrTypes&id_u=$id_u$" img="local://resources/desktop/5.png"/>
<gridItem text="广播信息" url="$server_path$/Api.ashx?function=getNewsList&id_u=$id_u$" img="local://resources/desktop/6.png"/>
<gridItem text="辅助软件" url="$server_path$/Api.ashx?function=getHelpTool" img="local://resources/desktop/7.png"/>
<gridItem text="退出系统" url="cmd://exit_app" img="local://resources/desktop/8.png"/>
</gridTable>
</body>
</page>
<?xml version="1.0" encoding="UTF-8"?>
<page pageId ="deskTop" pageTitle="我的桌面" pageVersion="1.0" cache="Check">
<body bgImage="$bgImage$">
<gridTable nameId="gid1" location="" size="" rows="3" cols="3">
<gridItem text="移动产品" url="$server_path$/Api.ashx?function=getGrpProduct&id_u=$id_u$" img="local://resources/desktop/2.png"/>
<gridItem text="集团产品" url="$server_path$/Api.ashx?function=getProduct&id_u=$id_u$" img="local://resources/desktop/3.png"/>
<gridItem text="知识库" url="$server_path$/Api.ashx?function=getKnowledgeTypes&id_u=$id_u$" img="local://resources/desktop/0.png"/>
<gridItem text="信息采集" url="$server_path$/Api.ashx?function=getCollType&id_u=$id_u$" img="local://resources/desktop/1.png"/>
<gridItem text="在线交流" url="$server_path$/Api.ashx?function=getMyQuestionList&id_u=$id_u$&id_acc=$id_acc$" img="local://resources/desktop/4.png"/>
<gridItem text="通讯录" url="$server_path$/Api.ashx?function=getAddrTypes&id_u=$id_u$" img="local://resources/desktop/5.png"/>
<gridItem text="广播信息" url="$server_path$/Api.ashx?function=getNewsList&id_u=$id_u$" img="local://resources/desktop/6.png"/>
<gridItem text="辅助软件" url="$server_path$/Api.ashx?function=getHelpTool" img="local://resources/desktop/7.png"/>
<gridItem text="退出系统" url="cmd://exit_app" img="local://resources/desktop/8.png"/>
</gridTable>
</body>
</page>
首先我是用fileInputStream去读的,代码如下:
Java代码
public static String readXml(String path){
StringBuffer sb = new StringBuffer();
try {
InputStream is = new FileInputStream(path);
byte[] buffer = new byte[1024];
while(true){
int length = is.read(buffer,0,1024);
if(length == -1) break;
length = is.read(buffer,0,1024);
sb.append(new String(buffer));
}
} catch (Exception e) {
e.printStackTrace();
}
责任编辑:小草