java文字排序小记
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java文字排序小记相关的知识,希望对你有一定的参考价值。
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<ClientVersion>()
@Override
public int compare(ClientVersion o1, ClientVersion o2)
Comparator<Object> 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文字排序小记的主要内容,如果未能解决你的问题,请参考以下文章