Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 NIO APIÏê½â

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

java²¢·¢±à³Ìʵ¼ù±Ê¼Ç

  1, ±£Ö¤Ḭ̈߳²È«µÄÈýÖÖ·½·¨: a, ²»Òª¿çÏ̷߳ÃÎʹ²Ïí±äÁ¿b, ʹ¹²Ïí±äÁ¿ÊÇfinalÀàÐ͵Äc, ½«¹²Ïí±äÁ¿µÄ²Ù×÷¼ÓÉÏͬ²½
    2, Ò»¿ªÊ¼¾Í½«ÀàÉè¼Æ³ÉḬ̈߳²È«µÄ, ±ÈÔÚºóÆÚÖØÐÂÐÞ¸´Ëü,¸üÈÝÒ×.
    3, ±àд¶àÏ̳߳ÌÐò, Ê×Ïȱ£Ö¤ËüÊÇÕýÈ·µÄ, Æä´ÎÔÙ¿¼ÂÇÐÔÄÜ.
    4, ÎÞ ......

Java¼¯ÈºÖ®session¹²Ïí½â¾ö·½°¸

      Ëæ×Å»¥ÁªÍøµÄÈÕÒæ׳´ó,ÍøÕ¾µÄpvºÍuv³ÉÏßÐÔ»òÕßÖ¸Êý±¶µÄÔö¼Ó.µ¥·þÎñÆ÷µ¥Êý¾Ý¿âÔçÒѾ­²»ÄÜÂú×ãʵ¼ÊÐèÇó.±ÈÈçÏñÊ¢´ó,ÌÔ±¦ÕâÑùµÄ´óÐÍÍøÂ繫˾,¸üÊÇÈç´Ë.
    ¼¯Èº,Ò²¾ÍÊÇÈÃÒ»×é¼ÆËã»ú·þÎñÆ÷Эͬ¹¤×÷,´ï½â¾ö´ó²¢·¢,´óÊý¾ÝÁ¿Æ¿¾±ÎÊÌâ.µ«ÊÇÔÚȺ¼¯ÖÐ,sessionÍùÍùÊÇÒ»¸ö±È½ÈÍ·ÌÛµÄÎ ......

ÓÃjavaÓïÑÔ ±àдµÄ³Ë·¨¿Ú¾÷±í

 public class Test {
 public static void main(String args[]) {
  int i;
  int j;
  for (i = 1; i <= 9; i++) {
   for (j = 1; j <= i; j++) {
    if (j * i <= 9)
     System.out.print(j ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ