• 解析服务器返回的输入流!!!!


    public class UpdateInfoParser {

    /**
    * 解析服务器返回的输入流
    *
    * @param is
    * @return 更新信息 null解析失败
    */
    public static UpdateInfo getUpdateInfos(InputStream is) {
    try {
    XmlPullParser parser = Xml.newPullParser();
    parser.setInput(is, "UTF-8");
    int type = parser.getEventType();
    UpdateInfo info = new UpdateInfo();
    while (type != XmlPullParser.END_DOCUMENT) {

    switch (type) {
    case XmlPullParser.START_TAG:
    if("version".equals(parser.getName())){
    String version = parser.nextText();
    info.setVersion(version);
    }else if("description".equals(parser.getName())){
    String description = parser.nextText();
    info.setDescription(description);
    }else if("path".equals(parser.getName())){
    String path = parser.nextText();
    info.setApkurl(path);
    }
    break;
    }
    type = parser.next();
    }
    return info;
    } catch (Exception e) {
    e.printStackTrace();
    return null;
    }

    }
    }

    public class UpdateInfo {
    private String version;
    private String description;
    private String apkurl;
    public String getVersion() {
    return version;
    }
    public void setVersion(String version) {
    this.version = version;
    }
    public String getDescription() {
    return description;
    }
    public void setDescription(String description) {
    this.description = description;
    }
    public String getApkurl() {
    return apkurl;
    }
    public void setApkurl(String apkurl) {
    this.apkurl = apkurl;
    }

    }

  • 相关阅读:
    CC
    codeforces 984 E. Elevator
    codeforces 984 D. XOR-pyramid
    codeforces 984 C. Finite or not?
    codeforces 984 B. Minesweeper
    codeforces 984 A. Game
    Loj #6000. 「网络流 24 题」搭配飞行员
    2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest 训练报告
    省赛训练 分块9题
    AC自动机 hdu 2222 Keywords Search
  • 原文地址:https://www.cnblogs.com/bravolove/p/4988161.html
Copyright © 2020-2023  润新知