JavaTM 2 Platform
Standard Ed. 5.0

java.nio.channels
ÀÎÅÍÆäÀ̽º ScatteringByteChannel

¸ðµç ½´ÆÛ ÀÎÅÍÆäÀ̽º:
Channel, Closeable, ReadableByteChannel
¾Ë·ÁÁø ±¸Çö Ŭ·¡½º ¸ñ·Ï:
DatagramChannel, FileChannel, Pipe.SourceChannel, SocketChannel

public interface ScatteringByteChannel
extends ReadableByteChannel

¹öÆÛ ¼ø¼­¿¡ ¹ÙÀÌÆ®¸¦ ÀоîµéÀÏ ¼ö Àִ ä³ÎÀÔ´Ï´Ù.

¡¸ºÐ»ê¡¹read Á¶ÀÛÀº 1ȸ ÀÇ È£Ãâ·Î ÁöÁ¤µÈ ¹öÆÛ ¼ø¼­ (º¹¼ö°¡´É)¿¡ ´ÜÀÏÀÇ ¹ÙÀÌÆ® ¼ø¼­¸¦ ÀоîµéÀÔ´Ï´Ù. º¸Åë, ºÐ»ê read´Â ƯÁ¤ÀÇ ³×Æ®¿öÅ© ÇÁ·ÎÅäÄÝÀ̳ª ÆÄÀÏ Çü½Ä (µ¥ÀÌÅ͸¦ 1°³ ÀÌ»óÀÇ °íÁ¤Àå Çì´õ¿Í °¡º¯ÀåÀÇ º»Ã¼·ÎºÎÅÍ µÇ´Â ¼¼±×¸ÕÆ®(segment)¿¡ Á¤¸®ÇÏ´Â ±â´ÉÀ» °¡Áö´Â °Í µî)À» ±¸ÇöÇÏ´Â °æ¿ì¿¡ µµ¿òÀÌ µË´Ï´Ù. ÀÌ°Í¿¡ À¯»çÇÑ ¡¸ÁýÁß¡¹Ãâ·Â Á¶ÀÛÀº, GatheringByteChannel ÀÎÅÍÆäÀ̽º·Î Á¤Àǵǰí ÀÖ½À´Ï´Ù.

µµÀÔµÈ ¹öÀü :
1.4

¸Þ¼­µå °³¿ä
 long read (ByteBuffer [] dsts)
          ÀÌ Ã¤³ÎÀÇ ¹ÙÀÌÆ® ¼ø¼­°¡ ÁöÁ¤µÈ ¹öÆÛ¿¡ ÀоîµéÀÔ´Ï´Ù.
 long read (ByteBuffer [] dsts, int offset, int length)
          ÀÌ Ã¤³ÎÀÇ ¹ÙÀÌÆ® ¼ø¼­°¡ ÁöÁ¤µÈ ¹öÆÛÀÇ ¼­ºê ¼ø¼­¿¡ ÀоîµéÀÔ´Ï´Ù.
 
ÀÎÅÍÆäÀ̽º java.nio.channels. ReadableByteChannel ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼­µå
read
 
ÀÎÅÍÆäÀ̽º java.nio.channels. Channel ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼­µå
close, isOpen
 

¸Þ¼­µåÀÇ »ó¼¼

read

long read(ByteBuffer [] dsts,
          int offset,
          int length)
          throws IOException 
ÀÌ Ã¤³ÎÀÇ ¹ÙÀÌÆ® ¼ø¼­°¡ ÁöÁ¤µÈ ¹öÆÛÀÇ ¼­ºê ¼ø¼­¿¡ ÀоîµéÀÔ´Ï´Ù.

ÀÌ ¸Þ¼­µå È£ÃâÀº ÀÌ Ã¤³Î·ÎºÎÅÍ ÃÖ´ë r ¹ÙÀÌÆ®¸¦ Àо·Á°í ÇÕ´Ï´Ù. r´Â ÀÌ ¸Þ¼­µåÀÇ È£Ãâ½Ã·Î ÁöÁ¤µÈ ¹öÆÛ ¹è¿­ÀÇ ÁöÁ¤µÈ ¼­ºê ¼ø¼­¿¡ Æ÷ÇԵǴ ÇÕ°è ¹ÙÀÌÆ®¼öÀÔ´Ï´Ù.

 dsts[offset]. remaining() + dsts[offset+1]. remaining() + ... + dsts[offset+length-1]. remaining()

±æÀÌ n (0 <= n <= r)ÀÇ ¹ÙÀÌÆ® ¼ø¼­°¡ ÀоÁø´Ù°í ÇÕ´Ï´Ù. ÀÌ ¼ø¼­ÀÇ ÃÖÃÊÀÇ dsts[offset]. remaining() ¹ÙÀÌÆ®±îÁö°¡ ¹öÆÛ dsts[offset]¿¡ Àü¼Û µÇ¾î ´ÙÀ½ÀÇ dsts[offset+1]. remaining() ¹ÙÀÌÆ®±îÁö°¡ ¹öÆÛ dsts[offset+1]¿¡ Àü¼Û µË´Ï´Ù. ÀÌ Ã³¸®´Â ¸ðµç ¹ÙÀÌÆ® ¼ø¼­°¡ ÁöÁ¤µÈ ¹öÆÛ¿¡ Àü¼Û µÉ ¶§±îÁö ¹Ýº¹ÇØÁý´Ï´Ù. °¢ ¹öÆÛ¿¡´Â ÃÖ´ëÇÑÀÇ ¹ÙÀÌÆ®°¡ Àü¼Û µÇ±â ¶§¹®¿¡ ÃÖÁ¾ °»½Å ¹öÆÛ¸¦ Á¦¿ÜÇÑ °³°³ÀÇ °»½Å ¹öÆÛÀÇ ÃÖÁ¾ÀûÀÎ À§Ä¡´Â ÀÌ ¹öÆÛÀÇ ¸®¹ÔÆ®¿Í µ¿ÀÏÇØÁý´Ï´Ù.

ÀÌ ¸Þ¼­µå´Â ¾ðÁ¦¶óµµ È£ÃâÇÒ ¼ö ÀÖ½À´Ï´Ù. ´Ù¸¸, ´Ù¸¥ thread°¡ ÀÌ Ã¤³Î¿¡ ´ëÇؼ­ Àбâ Á¶ÀÛÀ» °³½ÃÇÏ°í ÀÖ´Â °æ¿ì, ÀÌ ¸Þ¼­µåÀÇ È£ÃâÀº ÃÖÃÊÀÇ Á¶ÀÛÀÌ ³¡³¯ ¶§±îÁö ºí·Ï µË´Ï´Ù.

ÆĶó¹ÌÅÍ:
dsts - ¹ÙÀÌÆ®ÀÇ Àü¼Ûó ¹öÆÛ
offset - ÃÖÃÊÀÇ ¹ÙÀÌÆ®ÀÇ Àü¼Ûó°¡ µÇ´Â ¹öÆÛ ¹è¿­³»ÀÇ ¿ÀÇÁ¼Â(offset). dsts.length ¾Æ·¡ÀÇ Á¦·Î ¶Ç´Â Á¤ÀÇ ¼ö
length - ¾×¼¼½º °¡´ÉÇÑ ÃÖ´ë ¹öÆÛ¼ö. dsts.length - offset ¾Æ·¡ÀÇ Á¦·Î ¶Ç´Â Á¤ÀÇ ¼ö
¹Ýȯ°ª:
ÀÐÈù ¹®ÀÚ¼ö. Á¦·ÎÀΰ¡ ä³ÎÀÌ ½ºÆ®¸²ÀÇ ¸¶Áö¸·¿¡ À̸£°í ÀÖ´Â °æ¿ì´Â -1
¿¹¿Ü:
IndexOutOfBoundsException - offset ÆĶó¹ÌÅÍ¿Í length ÆĶó¹ÌÅÍÀÇ ÀüÁ¦ Á¶°ÇÀÌ Ã¤¿öÁöÁö ¾ÊÀº °æ¿ì
NonReadableChannelException - ÀÌ Ã¤³ÎÀÌ Àб⠰¡´ÉÇÏÁö ¾ÊÀº °æ¿ì
ClosedChannelException - ÀÌ Ã¤³ÎÀÌ Å¬·Î¿ìÁî ÇÏ°í ÀÖ´Â °æ¿ì
AsynchronousCloseException - read Á¶ÀÛÀÇ ÁøÇàÁß¿¡ ´Ù¸¥ thread¿¡ ÀÇÇØ ÀÌ Ã¤³ÎÀÌ Å¬·Î¿ìÁî µÇ¾úÀ» °æ¿ì
ClosedByInterruptException - read Á¶ÀÛÀÇ ÁøÇàÁß¿¡ ´Ù¸¥ thread·ÎºÎÅÍÀÇ ÀÎÅÍ·´Æ®°¡ ÀÖ¾ú±â ¶§¹®¿¡ ä³ÎÀÌ Å¬·Î¿ìÁî ÇØ, ÇöÀçÀÇ threadÀÇ ÀÎÅÍ·´Æ® »óÅ°¡ ¼³Á¤µÇ¾úÀ» °æ¿ì
IOException - ±× ¿ÜÀÇ ÀÔÃâ·Â ¿¡·¯°¡ ¹ß»ýÇßÀ» °æ¿ì

read

long read(ByteBuffer [] dsts)
          throws IOException 
ÀÌ Ã¤³ÎÀÇ ¹ÙÀÌÆ® ¼ø¼­°¡ ÁöÁ¤µÈ ¹öÆÛ¿¡ ÀоîµéÀÔ´Ï´Ù.

ÀÌ ¸Þ¼­µå¸¦ c.read(dsts) Çü½Ä¿¡¼­ È£ÃâÇßÀ» °æ¿ì, ´ÙÀ½ÀÇ È£Ãâ°ú °°Àº °á°ú¸¦ ¾òÀ» ¼ö ÀÖ½À´Ï´Ù.

 c.read(dsts, 0, srcs.length);

ÆĶó¹ÌÅÍ:
dsts - ¹ÙÀÌÆ®ÀÇ Àü¼Ûó ¹öÆÛ
¹Ýȯ°ª:
ÀÐÈù ¹®ÀÚ¼ö. Á¦·ÎÀΰ¡ ä³ÎÀÌ ½ºÆ®¸²ÀÇ ¸¶Áö¸·¿¡ À̸£°í ÀÖ´Â °æ¿ì´Â -1
¿¹¿Ü:
NonReadableChannelException - ÀÌ Ã¤³ÎÀÌ Àб⠰¡´ÉÇÏÁö ¾ÊÀº °æ¿ì
ClosedChannelException - ÀÌ Ã¤³ÎÀÌ Å¬·Î¿ìÁî ÇÏ°í ÀÖ´Â °æ¿ì
AsynchronousCloseException - read Á¶ÀÛÀÇ ÁøÇàÁß¿¡ ´Ù¸¥ thread¿¡ ÀÇÇØ ÀÌ Ã¤³ÎÀÌ Å¬·Î¿ìÁî µÇ¾úÀ» °æ¿ì
ClosedByInterruptException - read Á¶ÀÛÀÇ ÁøÇàÁß¿¡ ´Ù¸¥ thread·ÎºÎÅÍÀÇ ÀÎÅÍ·´Æ®°¡ ÀÖ¾ú±â ¶§¹®¿¡ ä³ÎÀÌ Å¬·Î¿ìÁî ÇØ, ÇöÀçÀÇ threadÀÇ ÀÎÅÍ·´Æ® »óÅ°¡ ¼³Á¤µÇ¾úÀ» °æ¿ì
IOException - ±× ¿ÜÀÇ ÀÔÃâ·Â ¿¡·¯°¡ ¹ß»ýÇßÀ» °æ¿ì

JavaTM 2 Platform
Standard Ed. 5.0

Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy µµ ÂüÁ¶ÇϽʽÿÀ.