从导出qq消息中提取qq好友

来源:互联网 发布:什么是阿里云 编辑:程序博客网 时间:2024/05/17 08:44
package nathan.qq.groupfriend;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.HashSet;import java.util.List;import java.util.Set;import net.mindview.util.TextFile;public class GroupFirendExport {public static void main(String[] args) {System.out.println(System.getProperty("user.dir"));String filePath = System.getProperty("user.dir")+ "\\src\\nathan\\qq\\groupfriend\\friends.txt"; // 保存为GBKSet<String> friends = new HashSet<String>();TextFile tf = new TextFile(filePath);for (String s : tf) {if (s.startsWith("消息对象")) {friends.add(s.substring(s.indexOf(":") + 1).trim());}}List<String> list = new ArrayList<String>(friends);Collections.sort(list);exportHtmlFile(list);}private static void exportHtmlFile(Collection<String> friends) {String html = "<html><body><table border='1'>";for (String s : friends) {html += ("<tr><td>" + s + "</td></tr>");}html += "</table></body></html>";TextFile.write(System.getProperty("user.dir") + "\\friends.html", html);}}


其中TextFile类来自《java 编程思想 4》


原创粉丝点击