91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 267KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發布日期: 2021-10-19
  • 語言: Java
  • 標簽:

資源簡介

java是現實的完整的天氣預報程序,保證能夠運行,需要的朋友下載

資源截圖

代碼片段和文件信息

package?com.arj.comm.util;

import?java.io.InputStream;
import?java.io.OutputStream;
import?java.io.OutputStreamWriter;
import?java.net.URL;
import?java.net.URLConnection;
import?javax.xml.parsers.DocumentBuilder;
import?javax.xml.parsers.DocumentBuilderFactory;
import?org.w3c.dom.Document;
import?org.w3c.dom.Node;
import?org.w3c.dom.NodeList;

public?class?WeatherReport?{
/**
?*?獲取SOAP的請求頭,并替換其中的標志符號為用戶輸入的城市
?*?
?*?編寫者:王景輝
?*?
?*?@param?city
?*????????????用戶輸入的城市名稱
?*?@return?客戶將要發送給服務器的SOAP請求
?*/
private?static?String?getSoapRequest(String?city)?{
StringBuilder?sb?=?new?StringBuilder();
sb
.append(“l?version=\“1.0\“?encoding=\“utf-8\“?>“
+?“lns:xsi=\“http://www.w3.org/2001/xmlSchema-instance\“?“
+?“xmlns:xsd=\“http://www.w3.org/2001/xmlSchema\“?“
+?“xmlns:soap=\“http://schemas.xmlsoap.org/soap/envelope/\“>“
+?“????lns=\“http://Webxml.com.cn/\“>“
+?““?+?city
+?“
????“
+?“
“);
return?sb.toString();
}

/**
?*?用戶把SOAP請求發送給服務器端,并返回服務器點返回的輸入流
?*?
?*?編寫者:王景輝
?*?
?*?@param?city
?*????????????用戶輸入的城市名稱
?*?@return?服務器端返回的輸入流,供客戶端讀取
?*?@throws?Exception
?*/
private?static?InputStream?getSoapInputStream(String?city)?throws?Exception?{
try?{
String?soap?=?getSoapRequest(city);
if?(soap?==?null)?{
return?null;
}
URL?url?=?new?URL(
“http://www.webxml.com.cn/WebServices/WeatherWebService.asmx“);
URLConnection?conn?=?url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);

conn.setRequestProperty(“Content-Length“?Integer.toString(soap
.length()));
conn.setRequestProperty(“Content-Type“?“text/xml;?charset=utf-8“);
conn.setRequestProperty(“SOAPAction“
“http://Webxml.com.cn/getWeatherbyCityName“);

OutputStream?os?=?conn.getOutputStream();
OutputStreamWriter?osw?=?new?OutputStreamWriter(os?“utf-8“);
osw.write(soap);
osw.flush();
osw.close();

InputStream?is?=?conn.getInputStream();
return?is;
}?catch?(Exception?e)?{
e.printStackTrace();
return?null;
}
}

/**
?*?對服務器端返回的xml進行解析
?*?
?*?編寫者:王景輝
?*?
?*?@param?city
?*????????????用戶輸入的城市名稱
?*?@return?字符串?用分割
?*/
public?static?String?getWeather(String?city)?{
try?{
Document?doc;
DocumentBuilderFactory?dbf?=?DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder?db?=?dbf.newDocumentBuilder();
InputStream?is?=?getSoapInputStream(city);
doc?=?db.parse(is);
NodeList?nl?=?doc.getElementsByTagName(“string“);
StringBuffer?sb?=?new?StringBuffer();
for?(int?count?=?0;?count? Node?n?=?nl.item(count);
if(n.getFirstChild().getNodeValue().equals(“查詢結果為空!“))?{
sb?=?new?StringBuffer(“#“)?;
brea

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????目錄??????????0??2009-07-04?17:08??天氣預報

?????目錄??????????0??2007-12-28?17:12??天氣預報\WebRoot

?????目錄??????????0??2007-12-28?17:44??天氣預報\WebRoot\src

?????目錄??????????0??2007-12-28?17:44??天氣預報\WebRoot\src\com

?????目錄??????????0??2007-12-28?17:44??天氣預報\WebRoot\src\com\arj

?????目錄??????????0??2007-12-28?17:44??天氣預報\WebRoot\src\com\arj\comm

?????目錄??????????0??2007-12-28?17:44??天氣預報\WebRoot\src\com\arj\comm\util

?????文件???????3623??2007-12-26?14:24??天氣預報\WebRoot\src\com\arj\comm\util\WeatherReport.java

?????目錄??????????0??2007-12-28?17:44??天氣預報\WebRoot\src\com\arj\servlet

?????文件????????940??2007-12-26?14:35??天氣預報\WebRoot\src\com\arj\servlet\WeatherServlet.java

?????文件????????768??2007-12-05?16:07??天氣預報\WebRoot\tianqi.jsp

?????目錄??????????0??2007-12-28?17:12??天氣預報\WebRoot\tqimgs

?????文件????????460??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\0.gif

?????文件????????458??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\1.gif

?????文件????????404??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\10.gif

?????文件????????453??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\11.gif

?????文件????????460??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\12.gif

?????文件????????450??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\13.gif

?????文件????????440??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\14.gif

?????文件????????436??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\15.gif

?????文件????????453??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\16.gif

?????文件????????458??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\17.gif

?????文件????????366??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\18.gif

?????文件????????438??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\19.gif

?????文件????????420??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\2.gif

?????文件????????451??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\20.gif

?????文件????????434??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\21.gif

?????文件????????441??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\22.gif

?????文件????????459??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\23.gif

?????文件????????450??2007-12-04?16:29??天氣預報\WebRoot\tqimgs\24.gif

............此處省略113個文件信息

評論

共有 條評論

相關資源