Java NIO????
???????????? ???????[ 2015/9/24 13:47:43 ] ??????????????????? ???????
????????????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)??
???????????д????????????????????????к?????????????????д??????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11