ÓÃJavaдÅÀÍøÒ³µÄС¹¤¾ß
ÆäʵҲ²»ÊÇÅÀÍøÒ³£¬Ö»ÊÇ´ÓÒ»¸öXMLÎļþÈ¡URL£¬È»ºó×¥È¡ÍøÒ³ÄÚÈÝ¡£
Ö÷ÒªÓм¸µã£¬±¸Íü£º
1. È«¾Ö´úÀí£¬ÉèÖÃÖ®ºóËùÓеÄURL¶¼Ê¹Óô˴úÀí£¬ÕâÑù¿ÉÒÔÖ±½Óµ÷ÓÃFileUtils.copyURLToFile£º
private void initProxy(String host, int port,
final String username, final String password) {
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username,
password.toCharArray());
}
});
System.setProperty("http.proxyType", "4");
System.setProperty("http.proxyPort",
Integer.toString(port));
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxySet", "true");
}
2. ÉèÖÃUser-Agent£¬ÓÐЩվµã½ûÖ¹Java×÷Ϊ·ÃÎʿͻ§¶Ë£¬±ØÐëͨ¹ýURLConnectionÉèÖÃUser-AgentÀ´Ä£Äâä¯ÀÀÆ÷£¬ËùÒÔ²»ÄÜÓÃFileUtils.copyURLToFile£¬¸´ÖÆÆäÔ´ÂëСÐÞ¸Äһϼ´¿É£º
URLConnection httpConnection = new URL(url).openConnection();
httpConnection.setRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
File dest = new File(path);
InputStream input = httpConnection.getInputStream();
try {
FileOutputStream output = FileUtils.openOutputStream(dest);
try {
IOUtils.copy(input, output);
} finally {
IOUtils.closeQuietly(output);
}
} finally {
IOUtils.closeQuietly(input);
}
3.dom4j¶ÁÈ¡³¬´óxmlÎļþ£¬Ê¹ÓÃevent basedģʽ·ÀÖ¹¶ÑÒç³ö´íÎó£º
reader.addHandler("/RDF/ExternalPage", new ElementHandler() {
public void onStart(ElementPath path) {
}
public void onEnd(ElementPath path) {
Element node = path.getCurrent();
// ½ÚµãÏà¹Ø²Ù×÷
// ¹Ø¼ü²Ù×÷£¬´ÓÄÚ´æµÄ½ÚµãÊ÷ÖÐÌÞ³ý½Úµã£¬ÊÍ·ÅÄÚ´æ
node.detach();
}
});
4.¶àÏ߳̿ÉÒÔÓÃjdk1.5мÓÈëµÄÏ̳߳Øjava.util.concurrent.ThreadPoolExecutor£¬·½±ãʵÓá£ÉÔ΢ҪעÒâµÄ¾ÍÊÇÔÚÌí¼ÓÍêËùÓÐÈÎÎñºó¼ÇµÃÖ´ÐÐÒ»ÏÂThreadPoolExecutor.shutdown()¡£
Ïà¹ØÎĵµ£º
ÕâÀïÖ»ÄÜ´ÓÏÔʾÊý¾ÝµÄjspÒ³ÃæÉϵ¼³öµ±Ç°Ò³ÃæµÄÊý¾Ý£¬ÕâЩÊý¾Ý¿ÉÒÔ´ÓÊý¾Ý¿â¶Á³ö£¬ÏÔʾµ½jspÒ³Ãæ£¬È»ºó¼ÓÒ»¶Î»°¾Í¿É°Ñµ±Ç°Ò³ÃæÊý¾Ý±£´æµ½excelÀïÃæ!
Èç´Óºǫ́¹ýÀ´Êý¾ÝÏÔʾµ½ showUser.jsp
È»ºó¼ÓÁ´½Óµ½ showExcel.jsp¾Í¿ÉÒÔÁË£¬ÔÚÕâ¸öÒ³ÃæÖ»¶àÁ˼¸ÐÐ×Ö£¬ÆäËûµÄ¶¼²»»áÏÔʾ°üÀ¨Ò³Ã棡µ«Õâ¸öÒ³ÃæÉϵÄÊý¾Ý¸úshowUser.js ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@ËÎÌå" ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@ËÎÌå" ......
ÔÎÄ£º http://blog.sina.com.cn/s/blog_4e0c121101000awr.html
(ÕâÊÇÎÒÄê³õдµÄһƪÎÄÕ£¬µ«³Ù³ÙûÓй«¿ª¡£ÓÐЩÄÚÈÝ¿ÉÄÜÒѾ¹ýʱ£¬µ«»¹ÊÇÖµµÃÒ»¶Á.)
¾¹ý½«½ü10ÄêµÄ·¢Õ¹ºó£¬Java EEÒѾÑݱäΪµ±Ç°ÆóÒµµÄÖ÷Á÷¼ÆËãÆ½Ì¨¡£¿ª·¢ÕßÔÙÒ²²»Äܹ»¼ò¼òµ¥µ¥µØ½«Java¿´³ÉÒ»ÖÖ±à³ÌÓïÑÔÁË£¬Æä²úÒµºÍ¼¼ÊõÁ´ÒÑ¾É ......
JAVA¶¯Ì¬°ó¶¨µÄÄÚ²¿ÊµÏÖ»úÖÆ
JAVAÐéÄâ»úµ÷ÓÃÒ»¸öÀà·½·¨Ê±£¬Ëü»á»ùÓÚ¶ÔÏóÒýÓõÄÀàÐÍ(ͨ³£ÔÚ±àÒëʱ¿ÉÖª)À´Ñ¡ÔñËùµ÷Óõķ½·¨¡£Ïà·´£¬µ±ÐéÄâ»úµ÷ÓÃÒ»¸öʵÀý·½·¨Ê±£¬Ëü»á»ùÓÚ¶ÔÏóʵ¼ÊµÄÀàÐÍ(Ö»ÄÜÔÚÔËÐÐʱµÃÖª)À´Ñ¡ÔñËùµ÷Óõķ½·¨£¬Õâ¾ÍÊǶ¯Ì¬°ó¶¨£¬ÊǶà̬µÄÒ»ÖÖ¡£¶¯Ì¬°ó¶¨Îª½â¾öʵ¼ÊµÄÒµÎñÎÊÌâÌṩÁ˺ܴóµÄÁé»îÐÔ£¬ÊÇÒ»Ö ......