ÓÃ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()¡£
Ïà¹ØÎĵµ£º
<!--
/* 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:"\@ËÎÌå" ......
JAVA String¶ÔÏóºÍ×Ö·û´®³£Á¿µÄ¹ØÏµ½âÎö
1 ×Ö·û´®ÄÚ²¿Áбí
JAVAÖÐËùÓеĶÔÏó¶¼´æ·ÅÔÚ¶ÑÀïÃæ£¬°üÀ¨String¶ÔÏó¡£×Ö·û´®³£Á¿±£´æÔÚJAVAµÄ.classÎļþµÄ³£Á¿³ØÖУ¬ÔÚ±àÒëÆÚ¾ÍÈ·¶¨ºÃÁË¡£
ÐéÄâ»úΪÿ¸ö±»×°ÔصÄÀàÐÍά»¤Ò»¸ö³£Á¿³Ø¡£³£Á¿³Ø¾ÍÊǸÃÀàÐÍËùÓó£Á¿µÄÒ»¸öÓÐÐò¼¯ºÏ£¬°üÀ¨Ö±½Ó³£Á¿(string¡¢integerºÍfloat point³ ......
ÔÎÄ£º http://blog.sina.com.cn/s/blog_4e0c121101000awr.html
(ÕâÊÇÎÒÄê³õдµÄһƪÎÄÕ£¬µ«³Ù³ÙûÓй«¿ª¡£ÓÐЩÄÚÈÝ¿ÉÄÜÒѾ¹ýʱ£¬µ«»¹ÊÇÖµµÃÒ»¶Á.)
¾¹ý½«½ü10ÄêµÄ·¢Õ¹ºó£¬Java EEÒѾÑݱäΪµ±Ç°ÆóÒµµÄÖ÷Á÷¼ÆËãÆ½Ì¨¡£¿ª·¢ÕßÔÙÒ²²»Äܹ»¼ò¼òµ¥µ¥µØ½«Java¿´³ÉÒ»ÖÖ±à³ÌÓïÑÔÁË£¬Æä²úÒµºÍ¼¼ÊõÁ´ÒÑ¾É ......
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.zip.CRC32;
public static void main(String[] args){
& ......