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

Java¶ÁÈ¡´óÎļþ

Óöµ½¹ýÕâÑùÒ»¸öÇé¿ö£¬ÐèÒªÓÃjava¶ÁÈ¡Ò»¸ö200MµÄÎı¾¸ñʽÎļþ£¬¶øÇÒ»¹ÐèÒª¶ÔÎļþµÄÄÚÈÝ×ö½âÎö£¬½øÐзִʡ£Èç¹ûÓÃJVMµÄĬ
ÈÏÉèÖã¬ÀûÓÃScannerÀàÖ»ÄܶÁ³ö4M´óСÄÚÈÝ£¬ÓÚÊÇÎÒ¾ÍÔÚÍøÉÏËÑË÷£¬µ«ÊÇÍøÉÏûÓÐÕÒµ½Ò»ÆªÎÄÕÂÊÇÎÒËùÐèÒªµÄÄÚÈÝ¡£ÓÚÊÇÎÒÖ»ºÃ·­thinking
in
java£¬·¢ÏÖÁËÒ»¸öjavaµÄnioÀïÓиöMappedByteBufferÀ࣬ËûµÄ×÷ÓÿÉÒÔ°ÑÒ»¸öÎļþÓ³Éäµ½ÄÚ´æÖУ¬È»ºó¾ÍÄÜÏñ·ÃÎÊÊý×éÒ»ÑùÈ¥¶ÁÈ¡Õâ
¸öÎļþ¡£ÓÚÊÇÎÒÔÚJDKÖвéÁËMappedByteBufferµÄÏêϸµÄÓ÷¨£¬È»ºó½«ÆäºÍScannerÀà½áºÏһϣ¬±ãÄܵõ½Ò»±ß¶ÁÈ¡´óÎļþ£¬Ò»±ß½âÎö¶Á
È¡µÄÄÚÈÝÁ˹¦ÄÜÁË£¬¾ßÌåµÄ´úÂëÈçÏ£º
public void readResource() {
   long fileLength = 0;
   final int BUFFER_SIZE = 0x300000;// 3MµÄ»º³å
  
   for(String fileDirectory:this.readResourceDirectory())//µÃµ½Îļþ´æ·Å·¾¶£¬ÎÒÕâÀïʹÓÃÁËÒ»¸ö·½·¨´ÓXMLÎļþÖжÁ³öÎļþµÄ
               //´æ·Å·¾¶£¬µ±È»Ò²¿ÉÒÔÓþø¶Ô·¾¶À´´úÌæÕâÀïµÄfileDriectory
   {
   File file = new File(fileDirectory);
   fileLength = file.length();
   try {
     MappedByteBuffer inputBuffer =
     new RandomAccessFile(file,"r").getChannel().map(FileChannel.MapMode.READ_ONLY, 0, fileLength);//¶ÁÈ¡´óÎļþ
    
     byte[] dst = new byte[BUFFER_SIZE];//ÿ´Î¶Á³ö3MµÄÄÚÈÝ
    
     for(int offset=0; offset < fileLength; offset+= BUFFER_SIZE)
     {
       if(fileLength - offset >= BUFFER_SIZE)
       {
           for(int i = 0;i < BUFFER_SIZE;i++)
           dst
= inputBuffer.get(offset + i);
       }
       else
       {
     


Ïà¹ØÎĵµ£º

Java_Ïß³Ì×ܽá

 ×ªÖÁ£ºhttp://sllereak.blog.163.com/blog
--ʲôÊÇÏß³Ì
 *Ïß³ÌÊÇÒ»¸ö³ÌÐòÀïÃ治ͬµÄÖ´Ðз¾¶
 *³ÌÐòÖ´ÐÐÔÚͬһʱ¼äÀïÃ棬ÿһ¸öÖ´ÐеķÖÖ§¾ÍÊÇÒ»¸öÏß³Ì
 *Ò»¸ö³ÌÐòµÄMain()·½·¨ÖеÄÖ´ÐÐÏß·³ÆΪ³ÌÐòµÄÖ÷Ïß³Ì
--½ø³ÌºÍÏß³Ì
 *½ø³ÌÊÇÒ»¸ö¾²Ì¬µÄ¸ÅÄµ±´úÂë±»javaÐéÄâ»ú¼ÓÔص½code segmentÖ ......

JavaÔ´´úÂëµÄÕÛÐйæÔò

һЩÆóÒµÔÚÕÐƸ³ÌÐòÔ±µÄʱºò£¬×Ü»áÌØÒâÌá³öÒ»¸öÒªÇ󣬼´ÒªÇó¾ßÓÐÁ¼ºÃµÄ±àÂë¹æ·¶¡£È·ÊµÏÖÔÚ³ÌÐò¿ª·¢ÈËÔ±ÒѾ­²»ÔÚÊǵ¥Ç¹Æ¥ÂíµÄµ¥¸É£¬¶øÊǽ²¾¿ÍÅÌå×÷Õ½¡£´Ëʱ¾ÍÒªÇóÍŶÓÄڵijËÔ±¶¼¿ÉÄܹ»ã¡ÊØ´úÂëµÄ±àд¹æ·¶£¬Õâ¶ÔÓÚ³ËÔ±Ö®¼ä¹²Ïí´úÂë¡¢ÅÅ´íµÈ×÷Òµ¶¼¾ßÓзdz£ÏÖʵµÄÒâÒå¡£ÕâÔÚJavaÓïÑÔÖе±È»Ò²²»ÀýÍâ¡£±ÊÕß½èÕâ´Î»ú»á£¬¾Í¸ú´ó¼Ò·Ö ......

Java¶à̬ÐÔµÄÀí½â

¶à̬µÄÄ¿µÄ
ͨ¹ýÀàÐÍת»»£¬°ÑÒ»¸ö¶ÔÏóµ±×÷ËüµÄ»ùÀà¶ÔÏó¶Ô´ý¡£
´ÓÏàͬµÄ»ùÀàÅÉÉú³öÀ´µÄ¶à¸öÅÉÉúÀà¿É±»µ±×÷ͬһ¸öÀàÐͶԴý£¬¿É¶ÔÕâЩ²»Í¬µÄÀàÐͽøÐÐͬÑùµÄ´¦Àí¡£
ÕâЩ²»Í¬ÅÉÉúÀàµÄ¶ÔÏóÏìӦͬһ¸ö·½·¨Ê±µÄÐÐΪÊÇÓÐËù²î±ðµÄ£¬ÕâÕýÊÇÕâЩÏàËƵÄÀàÖ®¼ä±Ë´ËÇø±ðµÄ²»Í¬Ö®´¦¡£
¶¯Ì¬°ó¶¨
½«Ò»¸ö·½·¨µ÷ÓúÍÒ»¸ö·½·¨Ö÷ÌåÁ¬½Óµ½Ò»Æð ......

JavaÏà¶Ô·¾¶×ܽá

 1.»ù±¾¸ÅÄîµÄÀí½â
¾ø¶Ô·¾¶£º¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶£¬(URLºÍÎïÀí·¾¶)ÀýÈ磺
C:xyz est.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶¡£http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸öURL¾ø¶Ô·¾¶¡£
Ïà¶Ô·¾¶£ºÏà¶ÔÓëij¸ö»ù׼Ŀ¼µÄ·¾¶¡£°üº¬WebµÄÏà¶Ô·¾¶£¨HTMLÖеÄÏà¶ÔĿ¼£©£¬ÀýÈ磺ÔÚ
Servl ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ