• Html工具类


    public class HtmlUtil {
    /**
    * 单例工具类
    */
    public HtmlUtil() {
    }



    public static Document getDoc(String url)throws IOException
    {
    File file = new File(url);

    if(file.exists())
    {
    Document doc = Jsoup.parse(file,"GBK");//Jsoup.parse(new URL(url).openStream(), "GBK", url);//
    return doc;
    }else{
    System.out.println("文件不存在:"+url);
    return null;
    }



    }

    public static Document getDocUrl(String url)throws IOException
    {
    File file = new File(url);

    if(file.exists())
    {

    return Jsoup.parse(new URL(url).openStream(), "GBK", url);
    }else{
    System.out.println("文件不存在:"+url);
    return null;
    }



    }

    public static Elements getTables(Document doc)
    {
    Elements tables = doc.getElementsByTag("table");
    return tables;
    }
    public static String subZeroAndDot(String s) {
    if (s != null && !s.equals(" ") && s.indexOf(".") > 0) {
    s = s.replaceAll("0+?$", "");// 去掉多余的0
    s = s.replaceAll("[.]$", "");// 如最后一位是.则去掉
    s = s.replaceAll(" ", "");// 如最后一位是.则去掉
    /*s = s.replaceAll(".", "");// 如最后一位是.则去掉
    s = s.replaceAll(".0", "");// 如最后一位是.则去掉
    s = StringUtils.toString(Math.floor(Double.parseDouble(s)));*/
    }
    return s;
    }

    public static double getMaxDouble(List list) {

    double max = (double) Collections.max(list);

    return max;
    }

    public static double getMinDouble(List list) {

    double min = (double) Collections.min(list);

    return min;
    }


    }
  • 相关阅读:
    输入和输出--java的NIO
    Java的NIO
    Java的nio
    输入和输出--java序列化机制
    输入和输出--javase中的路径
    输入和输出--重定向标准输入和输出
    输入和输出--RandomAccessFile类
    输入和输出--IO流
    输入和输出--File类
    无废话XML--DOM4J
  • 原文地址:https://www.cnblogs.com/luyuefei/p/13386502.html
Copyright © 2020-2023  润新知