package com.manage;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.*;

/**
 * @ProjectName:
 * @Description:
 * @Param 传输参数
 * @Return
 * @Author: 曾文和
 * @CreateDate: 2019/11/28 11:42
 * @UpdateUser: 曾文和
 * @UpdateDate: 2019/11/28 11:42
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class test {
    public static void main(String[] args) throws Exception{
        String str = "temperature_stat.htm";
        readfile(str);
    }
    public static String readfile(String filePath){
        File file = new File(filePath);
        InputStream input = null;
        try {
            input = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        StringBuffer buffer = new StringBuffer();
        byte[] bytes = new byte[1024];
        try {
            for(int n ; (n = input.read(bytes))!=-1 ; ){
                buffer.append(new String(bytes,0,n,"GBK"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        int i = buffer.toString().lastIndexOf("</TD>");
        String substring = buffer.substring(0, i);
        String substring1 = substring.substring(substring.length() - 4, substring.length());
        Float f = Float.valueOf(substring1);
        Math.round(f);
        System.out.println(substring1);
        return buffer.toString();
    }

    public String getBody(String val) {
        String start = "<body>";
        String end = "</body>";
        int s = val.indexOf(start) + start.length();
        int e = val.indexOf(end);
        return val.substring(s, e);
    }
}
