????????????buffer????????д???????channel???????????ж????????????????????????????????????NIO??????????????????????????д??????????????
????????NIO?????Java I/O????????????????????????????stream???ж?д??????????????????????д????NIO?У???????????????????????????NIO?????????? ????????????Java NIO?????
????NIO??????????
????· Java NIO????????????????????
????· ????????????????С????????????????
????· ?????????????????????????????????????д???
????· ???????????????
????· ?????????????????????????????mark??position??limit????????
????· ???????£??????????????????????
??????????????
?????????????????????????????????????е?????????????Buffer?????????????????????ByteBuffer????????Java NIO??????????????????
????· ByteBuffer
????· CharBuffer
????· ShortBuffer
????· IntBuffer
????· LongBuffer
????· FloatBuffer
????· DoubleBuffer
????· MappedByteBuffer
??????????????
???????????й????С?????????洢????“?????С”????????????С????????????????????????????????????????????????д????????????ú????????????????????????????
??????????????
??????д????????????????????????????????У?????????????????????λ?????λ????????????д??????????????????????????????????????????С???????????0 <= ???? <= ??????
??????????λ??
????λ????????????????????????????????λ???????????д?????У?λ?????????????????λ?á?λ????????????????
?????????????
????????????????????????????????? mark() ????λ????????????????? reset() ?????λ????????
??????????flip??clear??rewind
??????????flip()
????flip() ?????????????????????????? get ????????????μ?д?????С?flip() ??????????????λ??????λ?????0??
??????????clear()
????clear() ?????????????????????????? put ????????????μ?????С?clear() ?????????????????λ???????λ?????0??
??????????rewind()
????rewind() ??????????ζ?????????????????rewind()????????λ????0??
??????ζ?NIO??????
?????????????????????????????Buffer????? allocate(size) ???????????????? Buffer ????ByteBuffer byteBuffer = ByteBuffer.allocate(512)??
???????? flip ????????????ж???????byteBuffer.flip()??
???????????????????int numberOfBytes = fileChannel.read(byteBuffer)??
????????????????????????????char c = (char)byteBuffer.get()??
???????дNIO??????
????· ??????????????????????ByteBuffer byteBuffer = ByteBuffer.allocate(512); //???????512
????· д???????byteBuffer.put((byte) 0xff)??
???????????д????????????????????????к?????????????????д??????????????????????????