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

java nio Ö®MappedByteBuffer

 
ÆäʵÕÆÎÕ
MappedByteBuffer
²¢²»ÄÑ£¬Ö»Òª¼Çס“Èý·½Èý·¨ÈýÌØÐÔ”£¨ÎÒ×Ô¼º×ܽáµÄ£¬ºÇºÇ
~~
²»ÒªÈÓ¼¦µ°Å¶¡£¡£¡££©Õâ¾ä»°¾Í¿ÉÒÔÇáËɸ㶨£¡
MappedByteBuffer
Ö»ÊÇÒ»ÖÖÌØÊâµÄ
ByteBuffer
£¬¼´ÊÇ
ByteBuffer
µÄ×ÓÀà¡£
MappedByteBuffer
½«ÎļþÖ±½ÓÓ³Éäµ½Äڴ棨ÕâÀïµÄÄÚ´æÖ¸µÄÊÇÐéÄâÄڴ棬²¢²»ÊÇÎïÀíÄڴ棬ºóÃæ˵֤Ã÷ÕâÒ»µã£©¡£Í¨³££¬¿ÉÒÔÓ³ÉäÕû¸öÎļþ£¬Èç¹ûÎļþ±È½Ï´óµÄ»°¿ÉÒԷֶνøÐÐÓ³É䣬ֻҪָ¶¨ÎļþµÄÄǸö²¿·Ö¾Í¿ÉÒÔ¡£¶øÇÒ£¬Óë
ByteBuffer
Ê®·ÖÀàËÆ£¬Ã»Óй¹Ô캯Êý£¨Äã²»¿É
new MappedByteBuffer
£¨£©À´¹¹ÔìÒ»¸ö
MappedByteBuffer
£©£¬ÎÒÃÇ¿ÉÒÔͨ¹ý
java.nio.channels.FileChannel
µÄ
map()
·½·¨À´»ñÈ¡
MappedByteBuffer
¡£Æäʵ˵µÄͨË×Ò»µã¾ÍÊÇ
Map
°ÑÎļþµÄÄÚÈݱ»Ó³Ïñµ½¼ÆËã»úÐéÄâÄÚ´æµÄÒ»¿éÇøÓò£¬ÕâÑù¾Í¿ÉÒÔÖ±½Ó²Ù×÷ÄÚ´æµ±ÖеÄÊý¾Ý¶øÎÞÐè²Ù×÷µÄʱºòÿ´Î¶¼Í¨¹ý
I/O
È¥ÎïÀíÓ²Å̶ÁÈ¡Îļþ£¬ËùÒÔЧÂÊÉÏÓкܴóµÄÌáÉý£¡
ÈýÖÖ·½Ê½£º
      
      
FileChannel
ÌṩÁË
map
·½·¨À´°ÑÎļþÓ°ÉäΪÄÚ´æÓ³ÏñÎļþ£º
MappedByteBuffer map(int mode,long position,long size);
¿ÉÒÔ°ÑÎļþµÄ´Ó
position
¿ªÊ¼µÄ
size
´óСµÄÇøÓòÓ³ÉäΪÄÚ´æÓ³ÏñÎļþ£¬
mode
Ö¸³öÁË

¿É·ÃÎʸÃÄÚ´æÓ³ÏñÎļþµÄ·½Ê½£º
READ_ONLY,READ_WRITE,PRIVATE.                     
a. READ_ONLY,
£¨Ö»¶Á£©£º

ÊÔͼÐ޸ĵõ½µÄ»º³åÇø½«µ¼ÖÂÅ׳ö
ReadOnlyBufferException
.(MapMode.READ_ONLY
)
      
b. READ_WRITE
£¨¶Á
/
д£©£º

¶ÔµÃµ½µÄ»º³åÇøµÄ¸ü¸Ä×îÖÕ½«´«²¥µ½Îļþ£»¸Ã¸ü¸Ä¶ÔÓ³É䵽ͬһÎļþµÄÆäËû³ÌÐò²»Ò»¶¨ÊǿɼûµÄ¡£
(
MapMode.READ_WRITE
)
        c. PRIVATE
£¨×¨Óã©£º

¶ÔµÃµ½µÄ»º³åÇøµÄ¸ü¸Ä²»»á´«²¥µ½Îļþ£¬²¢ÇҸøü¸Ä¶ÔÓ³É䵽ͬһÎļþµÄÆäËû³ÌÐòÒ²²»ÊǿɼûµÄ£»Ïà·´£¬»á´´½¨»º³åÇøÒÑÐ޸IJ¿·ÖµÄרÓø±±¾¡£
(
MapMode.PRIVATE
)
 
Èý¸ö·½·¨£º

a. fore();
»º³åÇøÊÇ
READ_WRITE
ģʽÏ£¬´Ë·½·¨¶Ô»º³åÇøÄÚÈݵÄÐÞ¸ÄÇ¿ÐÐдÈëÎļþ

b. load()
½«»º³åÇøµÄÄÚÈÝÔØÈëÄڴ棬²¢·µ»Ø¸Ã»º³åÇøµÄÒýÓÃ

c.


Ïà¹ØÎĵµ£º

¹ØÓÚJavaÕ»Óë¶ÑµÄ˼¿¼

¹ØÓÚJavaÕ»Óë¶ÑµÄ˼¿¼
1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
¡¡¡¡2. Õ»µÄÓÅÊÆÊÇ£¬´æÈ¡ËٶȱȶÑÒª¿ì£¬½ö´ÎÓÚÖ±½ÓλÓÚCPUÖеļĴæÆ÷¡£µ«È±µãÊÇ£¬´æÔÚÕ»ÖеÄÊý¾Ý´óСÓëÉú´æÆÚ±ØÐëÊÇÈ·¶¨µÄ£¬È±·¦Áé»îÐÔ¡£ÁíÍ⣬ջÊý¾Ý¿ÉÒÔ¹²Ïí£¬Ïê¼ûµÚ3µ ......

JavaÏòÉÏתÐÍ

ͨË×Àí½âÏòÉÏתÐÍ£º
¾ÍÊÇ×ÓÀàתÐͳɸ¸Àà¡£
class A{}
class B extends A { }
A b = new B();
Õâ¸ö¾ÍÊÇÏòÉÏתÐÍ¡£
ÏòÉÏתÐÍ¿ÉÒÔÏñÏÂÃæÕâÌõÓï¾äÕâô¼òµ¥:
      Shape s =new Circle();
      ÕâÀ´´½¨Ò»¸öCircle¶ÔÏ ......

JavaÓÃforÑ­環Map


¸ù¾ÝJDK5µÄÐÂÌØÐÔ,ÓÃForÑ­»·Map,ÀýÈçÑ­»·MapµÄKey
Java´úÂë
for(String dataKey : paraMap.keySet())   {      
    System.out.println(dataKey );            &nbs ......

javaʵÏÖµÄftpÎļþÉÏ´«ÀýÌâ

1£ºÓÃhttpЭÒéÉÏ´«¸üÊʺÏweb±à³ÌµÄ·½±ã£»´«Ð¡ÓÚ1MÎļþËÙ¶ÈÒª±ÈÓÃftpЭÒéÉÏ´«ÎļþÂÔ¿ì¡£°²È«ÐԺ㻲»ÏñftpÄÇÑù£»±ØÐëÒªÆô¶¯Ò»¸öftp·þÎñ²ÅÐС£
2£ºÓÃftpЭÒéÉÏ´«Îļþ´óÓÚ1MµÄÎļþËٶȱÈhttp¿ì£»ÎļþÔ½´ó£»ÉÏ´«µÄËٶȾͱÈhttpÉÏ´«¿ìµÄ±¶ÊýÔ½´ó¡£¶øÇÒÓÃjava±àд³ÌÐò£»ftp±Èhttp·½±ã¡£ºÃ£¬·Ï»°ÉÙ˵£»ÎÒÃÇÏȴһ¸öʵÀýÀ´ÀíÐÔÈÏ ......

Çë×¢Òâ:javaÖÐûÓÐÒýÓô«µÝ


˵Ã÷:±¾ÎĵÄÊÊÓöÔÏóΪjava³õѧÕß¡¢Èç¹ûÓжÁÕß·¢ÏÖÎÄÕÂÖÐÓÐÐðÊö²»Í×Ö®´¦£¬ÇëÖ¸Õý¡£
½ñÌìÔÚÂÛ̳ÉÏÓÐÈËÌáÁËÒ»¸ö¹ØÓÚjavaÖе÷Óú¯ÊýʱÓÐûÓÐÒýÓô«µÝµÄÎÊÌâ,¿ÉνÊdz³µÄ²»¿É¿ª½»¡£ÓÐÈË˵javaÖ»ÓÐÖµ´«µÝ,Ò²ÓÐÈË˵java¼ÈÓÐÖµ´«µÝÒ²ÓÐÒýÓô«µÝ,ÄÇôjavaÖе½µ×ÓÐûÓÐÒýÓô«µÝÄØ£¬ÏÂÃæÎÒÀ´·ÖÎöһϡ£
Ò»¡¢Ê×ÏÈÀ´Ã÷È·Ò»ÏÂ"Öµ´«µÝ" ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ