Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Effective Java¶ÁÊé±Ê¼Ç

package chape8;
/**
* µÚ8ÕÂ
* µÚ46條£º
* for-eachÑ­環優ÏÈÓÚforÑ­環
* for(Element e : c)
* {
* dosomthing(e);
* }
* Õâ¸öÊÇjava1.5ÒÔÉϵİ汾µÄforÑ­»·µÄÊ×ÏÈ¿¼ÂǵÄд·¨
* ÒÔÏÂÊÇjava1.5ÒÔÇ°µÄ寫·¨
*  for (Iterator it = c.iterator();it.hasNext();)
{
it.next();
}
這兩個Ñ­環µÄ·½·¨¶¼±Èwhile·½·¨ÒªºÃ£¬45條ÖеÄ複製µÄ錯誤ÔÚÓõÚÒ»種Ñ­環¾Í
¿ÉÒÔ±ÜÃ⣻
總Ö®for eachÔÚ簡潔ºÍ預·Àbug·½ÃæÓÐÖø傳統µÄforÑ­環無·¨±ÈµÄ優勢£»並ÇÒ沒ÓÐÐÔÄÜ
損ʧ¡£應該¾¹¿ÉÄÜʹÓÃfor-each µ«ÊÇÓÐÏÂ麵Èý種Çé況無·¨Ê¹ÓÃfor each
1.過濾£ºÈç¹û±éÀúÒ»¸ö¼¯ºÏ ²¢É¾³ýÑ¡¶¨µÄÔªËØ ¾ÍÒªÓÃÏÔʾµÄµü´úÆ÷£¬ÕâÑù¿ÉÒÔµ÷ÓÃ
ËûµÄremove·½·¨
2.ת»»£ºÒª±éÀúÁбí»òÕßÊý×é ²¢È¡´úËûµÄ²¿·Ö»òÕßÈ«²¿ÔªËØÖµ ÒªÓõ½Êý×éµÄË÷Òý
3.ƽÐеü´úÒª²¢ÐбéÀú¶à¸ö¼¯ºÏ£»
* @author lee
*
*/
public class Chape46 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}


Ïà¹ØÎĵµ£º

Java NIO APIÏê½â

 
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......

JavaÖеÄIOÁ÷֪ʶ×ܽᣨת£©

×ܽáÒ»£º
Java IOµÄÒ»°ãʹÓÃÔ­Ôò£º
Ò»¡¢°´Êý¾ÝÀ´Ô´£¨È¥Ïò£©·ÖÀࣺ
1¡¢ÊÇÎļþ£º FileInputStream, FileOutputStream, FileReader, FileWriter
2¡¢ÊÇbyte[]£ºByteArrayInputStream, ByteArrayOutputStream
3¡¢ÊÇChar[]: CharArrayReader, CharArrayWriter
4¡¢ÊÇString: StringBufferInputStream, StringReader, StringW ......

jsp,java±àÂëÔ­Àí

Îļþ´ò¿ªÊ±ºòÊÇͨ¹ýÎļþÍ·À´È·¶¨ÎļþµÄ±àÂë
StreamReader   sr=new   StreamReader(@"F:\cym\temp\1.txt");  
  sr.CurrentEncoding   //·µ»Ø±àÂë
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎ ......

ʹÓà Java Native Interface µÄ×î¼Ñʵ¼ù

 Java™ ±¾»ú½Ó¿Ú£¨Java Native Interface£¬JNI£©ÊÇÒ»¸ö±ê×¼µÄ Java API£¬ËüÖ§³Ö½« Java ´úÂëÓëʹÓÃÆäËû±à³ÌÓïÑÔ±àдµÄ´úÂëÏ༯³É¡£Èç¹ûÄúÏ£ÍûÀûÓÃÒÑÓеĴúÂë×ÊÔ´£¬ÄÇô¿ÉÒÔʹÓà JNI ×÷ΪÄú¹¤¾ß°üÖеĹؼü×é¼þ —— ±ÈÈçÔÚÃæÏò·þÎñ¼Ü¹¹£¨SOA£©ºÍ»ùÓÚÔƵÄϵͳÖС£µ«ÊÇ£¬Èç¹ûÔÚʹÓÃʱδעÒâijЩÊÂÏÔò ......

Effective Java¶ÁÊé±Ê¼Ç

package chape8;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* µÚ°ËÕ ͨÓóÌÐòÉè¼Æ
* µÚ45Ìõ£º ½«¾Ö²¿±äÁ¿µÄ×÷ÓÃÓò¼õСµ½×îС
*   ½«¾Ö²¿±äÁ¿µÄ×÷ÓÃÓò×îС»¯¡£¿ÉÒÔÔöÇ¿´úÂëµÄ¿É¶ÁºÍ¿Éά»¤ÐÔ£¬²¢½µµÍ³ö´íµÄ¿ÉÄÜÐÔ
*   Ҫʹ×÷ÓÃÓò×îС£¬×îÓÐÁ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ