首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

XMPP群聊截图后在历史讯息中显示图片

2012-07-15 
XMPP群聊截图后在历史消息中显示图片截图后保存到xml中是用图片的信息来进行保存的,只需要通过图片的路径

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

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

代码如下

 String[] strs = body.split(" ");for(int i = 0; i < strs.length; i++){//表情if(strs[i].contains(":") || strs[i].contains("(") || strs[i].contains(")") ){try{URL emoticon_url = emoticonManager.getEmoticonURL(emoticonManager.getEmoticon(strs[i]));String emoticon_path = emoticon_url.getPath();emoticon_path = "file:///C|/" + emoticon_path.substring(emoticon_path.indexOf(":/") + 2);strs[i] = "<img src='"+ emoticon_path + "'/>";}catch (Exception e) {}finally{}}//截图if(strs[i].contains("Tmp://")){   String tmpPath = strs[i].substring(strs[i].indexOf("Tmp://") + 6, strs[i].indexOf("#"));   File rootPath =  new File(Spark.getSparkUserHome(), "/tempImages");                File f = new File(rootPath.getAbsolutePath(), tmpPath);                URL fileURL=null;try {fileURL = f.toURI().toURL();//本地URL  html可识别} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();}                String file_path=fileURL.getPath();                file_path = "file:///C|/" + file_path.substring(file_path.indexOf(":/") + 2);                if(f.exists()){                strs[i] = "<img src='"+ file_path + "'/>";                }else{                 strs[i] = "<img src='"+ f.getAbsolutePath() + "'/>";                }                }if(strs[i].contains("&lt;img&gt;")){//自定义的标签<img>strs[i]= strs[i].substring(0,strs[i].indexOf("&lt;img&gt;"));}builder.append(strs[i]);}

?效果如图所示:


XMPP群聊截图后在历史讯息中显示图片

热点排行