BlueSpace
思想有多遠,我們就能走多遠!
BlogJava
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
posts - 0, comments - 5, trackbacks - 0
<
2025年8月
>
日
一
二
三
四
五
六
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
留言簿
(1)
給我留言
查看公開留言
查看私人留言
我參與的團隊
深圳Java俱樂部(0/0)
文章分類
ajax(1)
hibernate(4)
java(21)
javasrcipt(13)
mysql數據庫(6)
spring
文章檔案
2009年8月 (1)
2009年3月 (2)
2008年10月 (1)
2008年7月 (3)
2008年6月 (11)
2008年3月 (1)
2008年2月 (1)
2007年12月 (11)
2007年11月 (3)
2007年9月 (13)
相冊
my photo
http://www.aygfsteel.com/beansoft
http://www.aygfsteel.com/sterning
http://www.aygfsteel.com/sterning
搜索
最新評論
1.?re: xfire aegis轉
評論內容較長,點擊標題查看
--啊啊啊
2.?re: xfire aegis轉
itn
--吃飯會非常
3.?re: distinct 與 order by
“select * from test group by name”這個SQL語句有問題,執行不了
--didi
4.?re: java讀取excel文件
good,so well,
--1111
5.?re: 正則表達式,不區分大小寫的替換
評論內容較長,點擊標題查看
--新手。
java HttpClient
/**/
/*
?*?Created?on?2007-1-20
?*
?*?TODO?To?change?the?template?for?this?generated?file?go?to
?*?Window?-?Preferences?-?Java?-?Code?Style?-?Code?Templates
?
*/
package
?test;
import
?org.apache.commons.httpclient.HttpClient;
import
?org.apache.commons.httpclient.HttpMethod;
import
?org.apache.commons.httpclient.methods.GetMethod;
import
?org.apache.commons.httpclient.methods.PostMethod;
/**?*/
/**
?*?
@author
?Administrator
?*
?*?TODO?To?change?the?template?for?this?generated?type?comment?go?to
?*?Window?-?Preferences?-?Java?-?Code?Style?-?Code?Templates
?
*/
public
?
class
?URLUtil
{
????
????
private
?
static
?String?url?
=
?
""
;
????
private
?
static
?
final
?String?loginUrl?
=
?
""
;
????
private
?
static
?HttpClient?client?
=
?
null
;
????
private
?
static
?PostMethod?method?
=
?
null
;
????
????
public
?
static
?
void
?setUrl(String?url1)
{
????????url?
=
?url1;
????}
????
????
public
?
static
?
void
?init()
{
????????
if
(client?
==
?
null
)
{
????????????
try
?
{
????????????????client?
=
?
new
?HttpClient();
????????????????method?
=
?
new
?PostMethod(loginUrl);
????????????????client.executeMethod(method);
????????????}
?
catch
?(Exception?e)?
{
????????????????System.out.println(
"
----系統初始化失敗!----
"
);
????????????????e.printStackTrace();
????????????}
????????}
????}
????
????
public
?
static
?String?getHtml()
{
????????String?contentStr?
=
?
""
;
????????init();
????????
try
{
????????????HttpMethod?postMethod?
=
?
new
?GetMethod(url);
????????????client.executeMethod(postMethod);
????????????contentStr?
=
?postMethod.getResponseBodyAsString();
????????????postMethod.releaseConnection();
????????}
catch
(Exception?e)
{
????????????release();
????????????getHtml();
????????}
????????
return
?contentStr;
????}
????
????
public
?
static
?
void
?release()
{
????????
if
(method?
!=
?
null
)method.releaseConnection();
????????
if
(client?
!=
?
null
)client?
=
?
null
;
????}
????
????
public
?
static
?
void
?main(String[]?args)
{
????????URLUtil.setUrl(
""
);
????????System.out.println(getHtml());
????}
}
posted on 2008-10-08 13:50
crazy
閱讀(642)
評論(0)
編輯
收藏
所屬分類:
java
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
java HttpClient
html正則處理
正則2
正則
java的時間處理
xfire 集合 aegis
xfire aegis轉
轉載
判斷是否存在中文
java正則表達式
Powered by:
BlogJava
Copyright ©2025 crazy
主站蜘蛛池模板:
潞城市
|
彩票
|
科尔
|
台山市
|
霍邱县
|
兴化市
|
林芝县
|
阳新县
|
绥阳县
|
肇州县
|
西藏
|
枣庄市
|
皋兰县
|
嵊州市
|
商水县
|
咸丰县
|
京山县
|
克东县
|
五常市
|
新郑市
|
江川县
|
虞城县
|
岑巩县
|
高邮市
|
静宁县
|
永定县
|
遵义县
|
新邵县
|
黄龙县
|
鲁甸县
|
安新县
|
原阳县
|
沧源
|
遂川县
|
田林县
|
玛沁县
|
延长县
|
肃南
|
四平市
|
永泰县
|
大渡口区
|