ʹÓÃJava·¢ËÍPOST¡¢GETÇëÇó
ʹÓÃJava·¢ËÍGET¡¢POSTÇëÇó
——½ÚÑ¡×Ô¡¶·è¿ñJava½²Òå¡·
URLµÄopenConnection()·½·¨½«·µ»ØÒ»¸öURLConnection¶ÔÏ󣬸öÔÏó±íʾӦÓóÌÐòºÍ URL Ö®¼äµÄͨÐÅÁ´½Ó¡£³ÌÐò¿ÉÒÔͨ¹ýURLConnectionʵÀýÏò¸ÃURL·¢ËÍÇëÇ󡢶ÁÈ¡URLÒýÓõÄ×ÊÔ´¡£
ͨ³£´´½¨Ò»¸öºÍ URL µÄÁ¬½Ó£¬²¢·¢ËÍÇëÇ󡢶ÁÈ¡´Ë URL ÒýÓõÄ×ÊÔ´ÐèÒªÈçϼ¸¸ö²½Ö裺
£¨1£©Í¨¹ýµ÷ÓÃURL¶ÔÏóopenConnection()·½·¨À´´´½¨URLConnection¶ÔÏó¡£
£¨2£©ÉèÖÃURLConnectionµÄ²ÎÊýºÍÆÕͨÇëÇóÊôÐÔ¡£
£¨3£©Èç¹ûÖ»ÊÇ·¢ËÍGET·½Ê½ÇëÇó£¬Ê¹ÓÃconnect·½·¨½¨Á¢ºÍÔ¶³Ì×ÊÔ´Ö®¼äµÄʵ¼ÊÁ¬½Ó¼´¿É£»Èç¹ûÐèÒª·¢ËÍPOST·½Ê½µÄÇëÇó£¬ÐèÒª»ñÈ¡URLConnectionʵÀý¶ÔÓ¦µÄÊä³öÁ÷À´·¢ËÍÇëÇó²ÎÊý¡£
£¨4£©Ô¶³Ì×ÊÔ´±äΪ¿ÉÓ㬳ÌÐò¿ÉÒÔ·ÃÎÊÔ¶³Ì×ÊÔ´µÄÍ·×ֶΡ¢»òͨ¹ýÊäÈëÁ÷¶ÁÈ¡Ô¶³Ì×ÊÔ´µÄÊý¾Ý¡£
ÔÚ½¨Á¢ºÍÔ¶³Ì×ÊÔ´µÄʵ¼ÊÁ¬½Ó֮ǰ£¬³ÌÐò¿ÉÒÔͨ¹ýÈçÏ·½·¨À´ÉèÖÃÇëÇóÍ·×ֶΣº
setAllowUserInteraction£ºÉèÖøÃURLConnectionµÄallowUserInteractionÇëÇóÍ·×ֶεÄÖµ¡£
setDoInput£ºÉèÖøÃURLConnectionµÄdoInputÇëÇóÍ·×ֶεÄÖµ¡£
setDoOutput£ºÉèÖøÃURLConnectionµÄdoOutputÇëÇóÍ·×ֶεÄÖµ¡£
setIfModifiedSince£ºÉèÖøÃURLConnectionµÄifModifiedSinceÇëÇóÍ·×ֶεÄÖµ¡£
setUseCaches£ºÉèÖøÃURLConnectionµÄuseCachesÇëÇóÍ·×ֶεÄÖµ¡£
³ý´ËÖ®Í⣬»¹¿ÉÒÔʹÓÃÈçÏ·½·¨À´ÉèÖᢻòÔö¼ÓͨÓÃÍ·×ֶΣº
setRequestProperty(String key, String value)£ºÉèÖøÃURLConnectionµÄkeyÇëÇóÍ·×ֶεÄֵΪvalue¡£ÈçÏ´úÂëËùʾ£º
conn.setRequestProperty("accept" , "*/*")
addRequestProperty(String key, String value)£ºÎª¸ÃURLConnectionµÄkeyÇëÇóÍ·×ֶεÄÔö¼ÓvalueÖµ£¬¸Ã·½·¨²¢²»»á¸²¸ÇÔÇëÇóÍ·×ֶεÄÖµ£¬¶øÊǽ«ÐÂÖµ×·¼Óµ½ÔÇëÇóÍ·×Ö¶ÎÖС£
µ±Ô¶³Ì×ÊÔ´¿ÉÓÃÖ®ºó£¬³ÌÐò¿ÉÒÔʹÓÃÒÔÏ·½·¨ÓÃÓÚ·ÃÎÊÍ·×ֶκÍÄÚÈÝ£º
Object getContent()£º»ñÈ¡¸ÃURLConnectionµÄÄÚÈÝ¡£
String getHeaderField(String name)£º»ñÈ¡Ö¸¶¨ÏìӦͷ×ֶεÄÖµ¡£
getInputStream()£º·µ»Ø¸ÃURLConnection¶ÔÓ¦µÄÊäÈëÁ÷£¬ÓÃÓÚ»ñÈ¡URLConnectionÏìÓ¦µÄÄÚÈÝ¡£
getOutputStream()£º·µ»Ø¸ÃURLConnection¶ÔÓ¦µÄÊä³öÁ÷£¬ÓÃÓÚÏòURLConnection·¢ËÍÇëÇó²ÎÊý¡£
×¢Ò⣺Èç¹û¼ÈҪʹÓÃÊäÈëÁ÷¶ÁÈ¡URLConnectionÏìÓ¦µÄÄÚÈÝ£¬Ò²ÒªÊ¹ÓÃÊä³öÁ÷·¢ËÍÇëÇó²ÎÊý£¬Ò»¶¨ÒªÏÈʹÓÃÊä³öÁ÷£¬ÔÙʹÓÃÊäÈëÁ÷¡£
getHeaderField·½·¨ÓÃÓÚ¸ù¾ÝÏìӦͷ×Ö¶ÎÀ´·µ»Ø¶ÔÓ¦µÄÖµ¡£¶øijЩͷ×Ö¶ÎÓÉÓÚ¾³£ÐèÒª·ÃÎÊ
Ïà¹ØÎĵµ£º
1¡¢JAVA¶ÁÈ¡Îļþ£¬±ÜÃâÖÐÎÄÂÒÂë¡£
/**
* ¶ÁÈ¡ÎļþÄÚÈÝ
*
* @param filePathAndName
* String Èç c:\\1.txt ¾ø¶Ô·¾¶
* @return boolean
*/
public static String readFile(String filePathAndName) {
String fileContent ......
¸ù¾ÝJDK5µÄÐÂÌØÐÔ,ÓÃForÑ»·Map,ÀýÈçÑ»·MapµÄKey
Java´úÂë
for(String dataKey : paraMap.keySet()) {
System.out.println(dataKey ); &nbs ......
1£¬Java3D ×÷Ϊsun¹«Ë¾½ÏÔçÍƳöµÄÒ»Ïî3d¼¼Êõ£¬ÊÇÒ»Öָ߶ȷâ×°µÄapi£¬¹¹½¨ÔÚopenglºÍdirect3dÖ®ÉÏ£¬¿ÉÒÔ˵ÊÇ×îÓÐÃûµÄjavaµÄ3d¼¼Êõ¡£ÓÉÓÚÖÖÖÖÔÒò£¨apiÉè¼Æ£¬ÃæÏòµÄÓû§²»Ã÷È·£©£¬java3dһֱûÓа취Á÷ÐУ¬²»¾ÃÇ°java3dµÄÍŶÓÐû²¼ÔÝÍ£¶Ôjava3dй¦ÄܵĿª·¢£¬×ª¶øΪJavaFX¿ª·¢3d äÖȾÒýÇ档ͬʱsunµÄÁíÒ»¸öÏîÄ¿ project wonder ......
µÚÒ»½Ú Êý¾ÝÁ÷µÄ»ù±¾¸ÅÄî
Àí½âÊý¾ÝÁ÷
Á÷Ò»°ã·ÖΪÊäÈëÁ÷£¨Input Stream£©ºÍÊä³öÁ÷£¨Output Stream£©Á½À࣬µ«ÕâÖÖ»®·Ö²¢²»ÊǾø¶ÔµÄ¡£±ÈÈçÒ»¸öÎļþ£¬µ±ÏòÆäÖÐдÊý¾Ýʱ£¬Ëü¾ÍÊÇÒ»¸öÊä³öÁ÷£»µ±´ÓÆäÖжÁÈ¡Êý¾Ýʱ£¬Ëü¾ÍÊÇÒ»¸öÊäÈëÁ÷¡£µ±È»£¬¼üÅÌÖ»ÊÇÒ»¸öÊýÈËÁ÷£¬¶øÆÁÄ»ÔòÖ»ÊÇÒ»¸öÊä³öÁ÷¡ ......
ÔÚ±àÒëandroid code ³öÏÖ°æ±¾²»¶ÔµÄÎÊÌ⣺
ÃèÊöÈçÏ£º
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.6.0_17".
The correct version is: 1.5.
Please follow the machine setup instructions at
http://source.android.com/download
ÍøÉÏÓÐÈËÌṩ½â¾ö·½·¨ÈçÏ ......