zoukankan      html  css  js  c++  java
  • 解析服务器返回的输入流!!!!

    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;
    }

    }

  • 相关阅读:
    论二级域名收集的各种姿势
    我喜欢你是寂静的-聂鲁达
    早晨充满-聂鲁达
    KALI Linux更新源
    lodash throttle和debounce
    lodash capitalize 首字母大写
    C# 格式化百分比
    c# PadLeft,PadRight用法
    对象名 XXX 无效。
    lambda 分组后的count
  • 原文地址:https://www.cnblogs.com/bravolove/p/4988161.html
Copyright © 2011-2022 走看看