打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
XMPP群聊截图后在历史消息中显示图片

截图后保存到xml中是用图片的信息来进行保存的,只需要通过图片的路径在本地找到对应的图片,加载到历史消息显示面板中即可。

代码如下

Java代码  
  1. String[] strs = body.split(" ");  
  2.                         for(int i = 0; i < strs.length; i++){  
  3.                             //表情  
  4.                             if(strs[i].contains(":") || strs[i].contains("(") || strs[i].contains(")") ){  
  5.                                 try{  
  6.                                 URL emoticon_url = emoticonManager.getEmoticonURL(emoticonManager.getEmoticon(strs[i]));  
  7.                                 String emoticon_path = emoticon_url.getPath();  
  8.                                 emoticon_path = "file:///C|/" + emoticon_path.substring(emoticon_path.indexOf(":/") + 2);  
  9.                                 strs[i] = "<img src='"+ emoticon_path + "'/>";  
  10.                             }catch (Exception e) {  
  11.                             }finally{  
  12.                             }  
  13.                             }  
  14.                             //截图  
  15.                             if(strs[i].contains("Tmp://")){  
  16.                                    String tmpPath = strs[i].substring(strs[i].indexOf("Tmp://") + 6, strs[i].indexOf("#"));  
  17.                                    File rootPath =  new File(Spark.getSparkUserHome(), "/tempImages");  
  18.                                     File f = new File(rootPath.getAbsolutePath(), tmpPath);  
  19.                                     URL fileURL=null;  
  20.                                     try {  
  21.                                         fileURL = f.toURI().toURL();//本地URL  html可识别  
  22.                                     } catch (MalformedURLException e) {  
  23.                                         // TODO Auto-generated catch block  
  24.                                         e.printStackTrace();  
  25.                                     }  
  26.                                     String file_path=fileURL.getPath();  
  27.                                     file_path = "file:///C|/" + file_path.substring(file_path.indexOf(":/") + 2);  
  28.                                     if(f.exists()){  
  29.                                         strs[i] = "<img src='"+ file_path + "'/>";  
  30.                                     }else{  
  31.                                         strs[i] = "<img src='"+ f.getAbsolutePath() + "'/>";  
  32.                                     }  
  33.                                       
  34.                             }  
  35.                             if(strs[i].contains("<img>")){//自定义的标签<img>  
  36.                                 strs[i]= strs[i].substring(0,strs[i].indexOf("<img>"));  
  37.                             }  
  38.                             builder.append(strs[i]);  
  39.                         }  

 效果如图所示:


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
javascript即时显示上传缩略图
JavaWeb上传下载文件
纯jsp的自定义的单个文件上载代码
用Servlvet实现文件上传的功能
用JSP实现文件上传功能
Arduino+w5100使用String类 解析GET请求
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服