JAVA ÅÀÍøÒ³ÓÃ ÀýÈç:http://www.126.com
/*
Function name: myGetHttpFile2
Description: ÅÀÍøÒ³ÓÃ
Input: URL ÀýÈç:http://www.126.com
Output: ×Ö·û´®,ÍøÒ³µÄHTML
*/
public String myGetHttpFile2(String url){
String authentication=null;
ArrayList al=new ArrayList();
String PageURL = url;
PageURL = url ;
ArrayList urlCollection=new ArrayList();
Hashtable ht=new Hashtable();
//´úÀí£¬Èç¹ûÒª´©¹ý´úÀí½«ÏÂÃæ×¢ÊÍÈ¡Ïû
//ht=System.getProperties();
//authentication = "Basic " + new sun.misc.BASE64Encoder().encode("´úÀíµÄÓû§:´úÀíµÄÃÜÂë".getBytes());
//ht.put("proxySet", "true");
//ht.put("proxyHost", "172.16.20.2");
//ht.put("proxyPort", "80");
String urlSource=PageURL;
StringBuffer htmlBuffer=new StringBuffer();
String returnStr=null;
int codeStart=0;
int codeEnd=0;
int linkCount=0;
String getURL=null;
String realURL=null;
String urlText=null;
int from=0;
int lenURL=0;
int firstLink=0;
int endLink=0;
boolean isNewsLink=false;
try
{
URL su = new URL (urlSource);
URLConnection conn = su.openConnection();
//conn.setRequestProperty("Proxy-Authorization", authentication);
InputStream imageSource=new URL(urlSource).openStream();
int ch;
while((ch=imageSource.read())>-1)
{
htmlBuffer.append((char)ch);
}
imageSource.close();
returnStr= new String(htmlBuffer);
returnStr=new String(returnStr.getBytes("ISO8859_1"),"GBK");
}
catch(Exception e)
{
}
if(returnStr!=null){
return returnStr ;
}else{
return "empty" ;
}
}
Ïà¹ØÎĵµ£º
1.»ù±¾¸ÅÄîµÄÀí½â
¾ø¶Ô·¾¶£º¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶£¬(URLºÍÎïÀí·¾¶)ÀýÈ磺 C:\xyz\test.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶¡£http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸ö URL¾ø¶Ô·¾¶¡£
Ïà¶Ô·¾¶£ºÏà¶ÔÓëij¸ö»ù׼Ŀ¼µÄ·¾¶¡£°üº¬WebµÄÏà¶Ô·¾¶(HTMLÖеÄÏà¶ÔĿ¼)£¬ÀýÈ磺ÔÚ ServletÖУ ......
½«ÏÂÔغóµÄÎļþ½â°ü£¬µÃµ½jxl.jar£¬·ÅÈëclasspath£¬°²×°¾ÍÍê³ÉÁË¡£
»ù±¾²Ù×÷
Ò»¡¢´´½¨Îļþ
ÄâÉú³ÉÒ»¸öÃûΪ“²âÊÔÊý¾Ý.xls”µÄExcelÎļþ£¬ÆäÖеÚÒ»¸ö¹¤×÷±í±»ÃüÃûΪ“µÚÒ»Ò³”£¬´óÖÂЧ¹ûÈçÏ£º
´úÂ루CreateXLS.java£©£º
//Éú³ÉExcelµÄÀà
import java.io.*;
import jxl.*;
import jxl.write. ......
1£®Hibernate¹¤×÷ÔÀí¼°ÎªÊ²Ã´ÒªÓã¿
ÔÀí£º
1.¶ÁÈ¡²¢½âÎöÅäÖÃÎļþ
2.¶ÁÈ¡²¢½âÎöÓ³ÉäÐÅÏ¢£¬´´½¨SessionFactory
3.´ò¿ªSesssion
4.´´½¨ÊÂÎñTransation
5.³Ö¾Ã»¯²Ù×÷
6.Ìá½»ÊÂÎñ
7.¹Ø±ÕSession
8.¹Ø±ÕSesstionFactory
ΪʲôҪÓãº
1. ¶ÔJDB ......
³£³£Óöµ½Êý×éÅÅÐòµÄÎÊÌâ.±ÈÈçÎÒÓÐÒ»¸öPersonÀà,ËüµÄʵÀý¶ÔÏó´æ´¢ÔÚArrayListÊý×éÖÐ,ÏÖÔÚÒª°ÑArrayListÊý×éÖеÄPerson¶ÔÏó°´ÕÕÄêÁäÅÅÐò.
ÆäʵÕâÖÖÇé¿ö¾³£Óöµ½.
ÏÂÃæ¸ø³öÔ´´úÂë:
1:Person.JavaÎļþ:-------------------------------
public class Person{
String name;
int age;
public Person(String name,int age){ ......
¶àÏ̳߳ÌÐò
¶ÔÓÚ¶àÏ̵߳ĺô¦Õâ¾Í²»¶à˵ÁË¡£µ«ÊÇ,ËüͬÑùÒ²´øÀ´ÁËijЩеÄÂé·³¡£Ö»ÒªÔÚÉè¼Æ³ÌÐòʱÌرðСÐÄÁôÒâ,¿Ë·þÕâЩÂé·³²¢²»ËãÌ«À§ÄÑ¡£
(1)ͬ²½Ïß³Ì
Ðí¶àÏß³ÌÔÚÖ´ÐÐÖбØÐ뿼ÂÇÓëÆäËûÏß³ÌÖ®¼ä¹²ÏíÊý¾Ý»òе÷Ö´ÐÐ״̬¡£Õâ¾Í ÐèҪͬ²½»úÖÆ¡£ÔÚJavaÖÐÿ¸ö¶ÔÏó¶¼ÓÐÒ»°ÑËøÓëÖ®¶ÔÓ¦¡£µ«Java²»Ìṩµ¥¶ÀµÄlockºÍunlock²Ù×÷¡£ ......