请问 eclipse 启动java项目是java开发的,为什么win平台的启动程序是exe类型的文件?谢谢

百度API服务和风天气获取当前天气信息,有需要的朋友可以参考下。工具类:package com.weather.import java.io.BufferedRimport java.io.InputSimport java.io.InputStreamRimport java.net.HttpURLCimport java.net.URL;public class WeatherUtil {/*** @param urlAll*
:请求接口* @param httpArg*
:参数* @return 返回结果*/public String request(String httpUrl, String httpArg) {BufferedReader reader =String result =StringBuffer sbf = new StringBuffer();httpUrl = httpUrl + &?& + httpAtry {URL url = new URL(httpUrl);HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setRequestMethod(&GET&);// 填入apikey到HTTP headerconnection.setRequestProperty(&apikey&,&&);connection.connect();InputStream is = connection.getInputStream();reader = new BufferedReader(new InputStreamReader(is, &UTF-8&));String strRead =while ((strRead = reader.readLine()) != null) {sbf.append(strRead);sbf.append(&/r/n&);}reader.close();result = sbf.toString();} catch (Exception e) {e.printStackTrace();}}}调用方:public static String httpUrl = &/heweather/weather/free&;public static String httpArg = &city=guilin&;String jsonResult = weatherUtil.request(httpUrl, httpArg);javascript&jquery:function weather(){
var weather =${jsonResult};/*EL表达式接收jsonResult*/
var weat = JSON.stringify(weather);
weat = weat.replace(&HeWeather data service 3.0&,&weather&);/*修改名称为:weather方便调用*/
var weJson = JSON.parse(weat);
var nowWeather = weJson.weather[0].basic.city+
& &+weJson.weather[0].now.cond.txt+
& &+weJson.weather[0].now.tmp+&°&+
& &+weJson.weather[0].now.wind.dir+weJson.weather[0].now.wind.
$(&#nowWeather&).html(nowWeather);/*nowWeather显示:城市
天气状况描述
alert(nowWeather);
weather();参考:/apiworks/servicedetail/478.html和风天气文档:/documents/condition-code
Spark2.1.1&spark写入Hbase
最新教程周点击榜
8Spark2.1.1&spark写入Hbase的三种方法性能对
微信扫一扫ASP.net(c#)打造24小时天气预报及实时天气
本文详细介绍关于ASP.NET的实时天气及24小时天气预报 修改其中的url获得其他城市的天气情况的文章专题。
ASP.NET的实时天气及24小时天气预报(C#)& 修改其中的url获得其他城市的天气情况& 如广州为:&
/forecast/CHXX0037_c.html& 注意仅适用于获得yahoo上的天气预报&GetWeather.aspx& ———————————–&&
代码如下:&%@&Page&language=”c#”&Codebehind=”GetWeather.aspx.cs”&AutoEventWireup=”false”&Inherits=”test.GetWeather”&%&&& &!DOCTYPE&HTML&PUBLIC&“-//W3C//DTD&HTML&4.0&Transitional//EN”&&&& &HTML&&& &HEAD&&& &title&GetWeather&/title&&& &meta&name=”GENERATOR”&Content=”Microsoft&Visual&Studio&7.0″&&& &meta&name=”CODE_LANGUAGE”&Content=”C#”&&& &meta&name=”vs_defaultClientScript”&content=”JavaScript”&&& &meta&name=”vs_targetSchema”&content=”/intellisense/ie5″&&& &/HEAD&&& &body&&& &form&id=”GetWeather”&method=”post”&runat=”server”&&& &FONT&face=”宋体”&&& &P&&& &asp:Label&id=”lblWeather”&runat=”server”&Weather&/asp:Label&&/P&&& &P&&& &asp:Button&id=”btnGet”&runat=”server”&Text=”Get&Weather”&& &/asp:Button&&/P&&& &P&&& &asp:Label&id=”Weather2″&runat=”server”&24小时天气&/asp:Label&&/P&&& &P&&& &asp:Button&id=”btnGet2″&runat=”server”&Text=”天气预报”&& &/asp:Button&&/P&&& &/FONT&&& &/form&&& &/body&&& &/HTML&getWeather.aspx.cs& —————————————&
代码如下:using&S&& using&System.C&& using&ponentM&& using&System.D&& using&System.D&& using&System.W&& using&System.Web.SessionS&& using&System.Web.UI;&& using&System.Web.UI.WebC&& using&System.Web.UI.HtmlC&& using&System.N&& using&System.IO;&&
namespace&test&& {&&
public&class&GetWeather&:&System.Web.UI.Page&& {&& protected&System.Web.UI.WebControls.Label&lblW&& protected&System.Web.UI.WebControls.Label&Weather2;&& protected&System.Web.UI.WebControls.Button&btnGet2;&& protected&System.Web.UI.WebControls.Button&btnG&&
private&void&Page_Load(object&sender,&System.EventArgs&e)&& {&& //&Put&user&code&to&initialize&the&page&here&& }&&
#region&Web&Form&Designer&generated&code&& override&protected&void&OnInit(EventArgs&e)&& {&& //&& //&CODEGEN:&This&call&is&required&by&the&ASP.NET&Web&Form&Designer.&& //&& InitializeComponent();&& base.OnInit(e);&& }&&
///&&summary&&& ///&Required&method&for&Designer&support&–&do&not&modify&& ///&the&contents&of&this&method&with&the&code&editor.&& ///&&/summary&&& private&void&InitializeComponent()&& {&& this.btnGet.Click&+=&new&System.EventHandler(this.btnGet_Click);&& this.btnGet2.Click&+=&new&System.EventHandler(this.btnGet2_Click);&& this.Load&+=&new&System.EventHandler(this.Page_Load);&&
}&& #endregion&&
private&void&btnGet_Click(object&sender,&System.EventArgs&e)&& {&&
WebRequest&wreq=WebRequest.Create& (“/forecast/CHXX0037_c.html”);&&
HttpWebResponse&wresp=(HttpWebResponse)wreq.GetResponse();&&
string&HTML&=””;&& Stream&s=wresp.GetResponseStream();&&
StreamReader&objReader&=&new&StreamReader(s);&&
string&sLine&=&“”;&& int&i&=&0;&&
while&(sLine!=null)&& {&& i++;&& sLine&=&objReader.ReadLine();&& if&(sLine!=null)&& HTML&+=&sL&& }&&
String&temp=&“”;&& int&start,&&
start&=&HTML.IndexOf(“&!–&CURCON–&”,0,HTML.Length);&&
stop&=&HTML.IndexOf(“&!–&END&CURCON–&”,0,HTML.Length);&&
temp&=&HTML.Substring(start,&stop&–&start);&& start&=&temp.IndexOf(“&b&”);&& stop&=&temp.IndexOf(“&/b&”);&&
string&degree&=&temp.Substring(start+3,stop&–&start&-3);&&
start&=&temp.IndexOf(“&img”);&& stop&=&temp.IndexOf(“&/td&”,start);&&
string&img&=&temp.Substring(start,stop&–&start);&& lblWeather.Text&=&degree&+&“&br&”&+&&&
private&void&btnGet2_Click(object&sender,&System.EventArgs&e)&& {&& WebRequest&wreq=WebRequest.Create& (“http://cn./CHXX/CHXX0037/index_c.html”);&&
HttpWebResponse&wresp=(HttpWebResponse)wreq.GetResponse();&&
string&HTML&=””;&& Stream&s=wresp.GetResponseStream();&&
StreamReader&objReader&=&new&StreamReader(s,System.Text.Encoding.GetEncoding(“GB;));&&
string&sLine&=&“”;&& int&i&=&0;&&
while&(sLine!=null)&& {&& i++;&& sLine&=&objReader.ReadLine();&& if&(sLine!=null)&& HTML&+=&sL&& }&&
String&temp=&“”;&& int&start,&&
start&=&HTML.IndexOf(“&table&border=0&cellpadding=2&& cellspacing=1&bgcolor=9999cc&width=\”85%\”&”,0,HTML.Length);&&
stop&=&HTML.IndexOf(“&/table&”,start)+8;&&
temp&=&HTML.Substring(start,&stop&–&start);&& Weather2.Text&=&&& }&& }&& }&&请注明转自chinazhan中国站长
相关文章:
暂时还没有评论.

我要回帖

更多关于 eclipsejavamarswin64 的文章

 

随机推荐