⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 yahoo 所使用的 天气预报的解析代码
💻 JAVA
字号:
/*
 * Main.java
 *
 * Created on May 25, 2007, 2:33 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package yweatherbeta;

import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import org.xml.sax.SAXException;

/**
 *
 * @author BEN
 */
public class Main {
    
    /** Creates a new instance of Main */
    public Main() throws XPathExpressionException {
        try {
            System.out.println("Initialize a parser with location set to New York");
            YWeatherParser parser = new YWeatherParser("USNY0996",'f');
            parser.parse();
            System.out.println("city: "+parser.getCity());
            System.out.println("region: "+parser.getRegion());
            
            System.out.println("Set location to 91791");
            parser.setLocation("91791");
            parser.parse();
            System.out.println("city: "+parser.getCity());
            System.out.println("region: "+parser.getRegion());
            System.out.println("country: "+parser.getCountry());
            System.out.println("language: "+parser.getLanguage());
            System.out.println("TTL: "+parser.getTTL());
            System.out.println("LastBuildDate: "+parser.getLastBuildDate());
            System.out.println("Wind chill: "+parser.getWindChill());
            System.out.println("Wind direction: "+parser.getWindDirection());
            System.out.println("Wind speed: "+parser.getWindSpeed());
            System.out.println("Degree Unit: "+parser.getDistanceUnit());
            System.out.println("Pressure Unit: "+parser.getPressureUnit());
            System.out.println("Speed Unit: "+parser.getSpeedUnit());
            System.out.println("Humidity: "+parser.getHumidity());
            Forecast forecast = parser.getForecast(YWeatherParser.TODAY);
            System.out.println("Forecast day: "+forecast.getDay());
            System.out.println("Forecast date: "+forecast.getDate());
            System.out.println("Forecast low: "+forecast.getTempLow());
            System.out.println("Forecast high: "+forecast.getTempHigh());
            System.out.println("Forecast condition: "+forecast.getCondition());
            forecast = parser.getForecast(YWeatherParser.TOMORROW);
            System.out.println("Forecast tomorrow day: "+forecast.getDay());
            System.out.println("Forecast tomorrow date: "+forecast.getDate());
            System.out.println("Forecast tomorrow low: "+forecast.getTempLow());
            System.out.println("Forecast tomorrow high: "+forecast.getTempHigh());
            System.out.println("Forecast tomorrow  condition: "+forecast.getCondition());
        } catch (ParserConfigurationException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (YWeatherParserException ex) {
            ex.printStackTrace();
        }
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            Main main = new Main();
        } catch (XPathExpressionException ex) {
            ex.printStackTrace();
        }
        // TODO code application logic here
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -