List list = new ArrayList();
        Document document = Jsoup.parse(new File("E:\\test\\erp_index.html"), "UTF-8");
        final Elements bookname = document.getElementsByClass("bookname");
        final Elements bookzz = document.getElementsByClass("bookzz");
        final Elements bookjs = document.getElementsByClass("bookjs");
        final Elements bookbtn = document.getElementsByClass("bookbtn");
        for (int i = 0; i < bookname.size(); i++) {
            String s = bookname.get(i).select("a").attr("href");
            LogUtil.info(bookname.get(i).text() + "," + bookzz.get(i).text() + "," + bookbtn.get(i).text());
            list.add(new ClientVersion(bookbtn.get(i).text(), bookname.get(i).text()+"<-->"+s));
        }
        LogUtil.info("一共多少:" + bookname.size());

        Collections.sort(list, new Comparator() {
            @Override
            public int compare(ClientVersion o1, ClientVersion o2) {
                Comparator compare = Collator.getInstance(java.util.Locale.CHINA);
                return ((Collator) compare).compare(o1.getClient(), o2.getClient());
            }
        });
        final Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            final ClientVersion next = (ClientVersion)iterator.next();
            LogUtil.info(next.getClient() + "-->" + next.getClientVersion());
        } 
  

java文字排序小记_第1张图片

你可能感兴趣的:(java文字排序小记,编程java)