java核心技術(shù)-NIO

1、reactor(反應(yīng)器)模式

  使用單線(xiàn)程模擬多線(xiàn)程,提高資源利用率和程序的效率,增加系統(tǒng)吞吐量。下面例子比較形象的說(shuō)明了什么是反應(yīng)器模式:

  一個(gè)老板經(jīng)營(yíng)一個(gè)飯店,

  傳統(tǒng)模式 - 來(lái)一個(gè)客人安排一個(gè)服務(wù)員招呼,客人很滿(mǎn)意;(相當(dāng)于一個(gè)連接一個(gè)線(xiàn)程)

  后來(lái)客人越來(lái)越多,需要的服務(wù)員越來(lái)越多,資源條件不足以再請(qǐng)更多的服務(wù)員了,傳統(tǒng)模式已經(jīng)不能滿(mǎn)足需求。老板之所以為老板自然有過(guò)人之處,老板發(fā)現(xiàn),服務(wù)員在為客人服務(wù)時(shí),當(dāng)客人點(diǎn)菜的時(shí)候,服務(wù)員基本處于等待狀態(tài),(阻塞線(xiàn)程,不做事)。

  于是乎就讓服務(wù)員在客人點(diǎn)菜的時(shí)候,去為其他客人服務(wù),當(dāng)客人菜點(diǎn)好后再招呼服務(wù)員即可。 --反應(yīng)器(reactor)模式誕生了

  飯店的生意紅紅火火,幾個(gè)服務(wù)員就足以支撐大量的客流量,老板用有限的資源賺了更多的money~~~~^_^

通道:類(lèi)似于流,但是可以異步讀寫(xiě)數(shù)據(jù)(流只能同步讀寫(xiě)),通道是雙向的,(流是單向的),通道的數(shù)據(jù)總是要先讀到一個(gè)buffer 或者 從一個(gè)buffer寫(xiě)入,即通道與buffer進(jìn)行數(shù)據(jù)交互。

通道類(lèi)型:

FileChannel:從文件中讀寫(xiě)數(shù)據(jù)。

DatagramChannel:能通過(guò)UDP讀寫(xiě)網(wǎng)絡(luò)中的數(shù)據(jù)。

SocketChannel:能通過(guò)TCP讀寫(xiě)網(wǎng)絡(luò)中的數(shù)據(jù)。

ServerSocketChannel:可以監(jiān)聽(tīng)新進(jìn)來(lái)的TCP連接,像Web服務(wù)器那樣。對(duì)每一個(gè)新進(jìn)來(lái)的連接都會(huì)創(chuàng)建一個(gè)SocketChannel。

 - FileChannel比較特殊,它可以與通道進(jìn)行數(shù)據(jù)交互, 不能切換到非阻塞模式,套接字通道可以切換到非阻塞模式;

緩沖區(qū)?- 本質(zhì)上是一塊可以存儲(chǔ)數(shù)據(jù)的內(nèi)存,被封裝成了buffer對(duì)象而已!

緩沖區(qū)類(lèi)型:

ByteBuffer

MappedByteBuffer

CharBuffer

DoubleBuffer

FloatBuffer

IntBuffer

LongBuffer

ShortBuffer

常用方法:

allocate() - 分配一塊緩沖區(qū)

put() - 向緩沖區(qū)寫(xiě)數(shù)據(jù)

get() - 向緩沖區(qū)讀數(shù)據(jù)

filp() - 將緩沖區(qū)從寫(xiě)模式切換到讀模式

clear() - 從讀模式切換到寫(xiě)模式,不會(huì)清空數(shù)據(jù),但后續(xù)寫(xiě)數(shù)據(jù)會(huì)覆蓋原來(lái)的數(shù)據(jù),即使有部分?jǐn)?shù)據(jù)沒(méi)有讀,也會(huì)被遺忘;

compact() - 從讀數(shù)據(jù)切換到寫(xiě)模式,數(shù)據(jù)不會(huì)被清空,會(huì)將所有未讀的數(shù)據(jù)copy到緩沖區(qū)頭部,后續(xù)寫(xiě)數(shù)據(jù)不會(huì)覆蓋,而是在這些數(shù)據(jù)之后寫(xiě)數(shù)據(jù)

mark() - 對(duì)position做出標(biāo)記,配合reset使用

reset() - 將position置為標(biāo)記值

緩沖區(qū)的一些屬性:

capacity - 緩沖區(qū)大小,無(wú)論是讀模式還是寫(xiě)模式,此屬性值不會(huì)變;

position - 寫(xiě)數(shù)據(jù)時(shí),position表示當(dāng)前寫(xiě)的位置,每寫(xiě)一個(gè)數(shù)據(jù),會(huì)向下移動(dòng)一個(gè)數(shù)據(jù)單元,初始為0;最大為capacity - 1,切換到讀模式時(shí),position會(huì)被置為0,表示當(dāng)前讀的位置

limit - 寫(xiě)模式下,limit 相當(dāng)于capacity 表示最多可以寫(xiě)多少數(shù)據(jù),切換到讀模式時(shí),limit 等于原先的position,表示最多可以讀多少數(shù)據(jù)。

非直接緩沖區(qū):通過(guò)allocate() 方法 分配緩沖區(qū),將緩沖區(qū)建立在JVM內(nèi)存中

直接緩沖區(qū):通過(guò)allocateDirect() 方法直接緩沖區(qū) 將緩沖區(qū)建立在物理內(nèi)存中

2.1 關(guān)于緩沖區(qū)各個(gè)屬性的測(cè)試

String str ="abcde";//1. 分配一個(gè)指定大小的緩沖區(qū)ByteBuffer buf = ByteBuffer.allocate(1024);? ? ? ? ? ? ? ? System.out.println("--------------allocate()----------------");? ? ? ? System.out.println(buf.position());//0System.out.println(buf.limit());//1024System.out.println(buf.capacity());//1024//2. 利用put存入數(shù)據(jù)到緩沖區(qū)中去buf.put(str.getBytes());? ? ? ? ? ? ? ? System.out.println("----------------put()-------------------");? ? ? ? System.out.println(buf.position());//5System.out.println(buf.limit());//1024System.out.println(buf.capacity());//1024//3. 切換到讀取模式buf.flip();? ? ? ? ? ? ? ? System.out.println("----------------flip()------------------");? ? ? ? System.out.println(buf.position());//0System.out.println(buf.limit());//5System.out.println(buf.capacity());//1024//4. 利用get() 讀取緩沖區(qū)中的數(shù)據(jù)byte[] dst =newbyte[buf.limit()];? ? ? ? buf.get(dst);? ? ? ? System.out.println(newString(dst,0,dst.length));? ? ? ? ? ? ? ? System.out.println("----------------get()------------------");? ? ? ? System.out.println(buf.position());//5System.out.println(buf.limit());//5System.out.println(buf.capacity());//1024//5.可重復(fù)讀buf.rewind();? ? ? ? ? ? ? ? System.out.println("----------------rewind()------------------");? ? ? ? System.out.println(buf.position());//0System.out.println(buf.limit());//5System.out.println(buf.capacity());//1024//6.clear(): 清空緩沖區(qū), 但是緩沖區(qū)的數(shù)據(jù)依然存在, 但是處于被遺忘的狀態(tài)buf.clear();? ? ? ? ? ? ? ? System.out.println("----------------clear()-------------------");? ? ? ? System.out.println(buf.position());//0System.out.println(buf.limit());//1024System.out.println(buf.capacity());//1024byte[] newByte =newbyte[buf.limit()];? ? ? ? buf.get(newByte);? ? ? ? System.out.println(newString(newByte,0,newByte.length));

2.2 關(guān)于通道的使用

1.利用通道進(jìn)行 文件的復(fù)制 非直接緩沖區(qū)

FileInputStream fis =null;? ? ? ? FileOutputStream fos =null;? ? ? ? FileChannel inChannel =null;? ? ? ? FileChannel outChannel =null;try{? ? ? ? ? ? fis =newFileInputStream("1.jpg");? ? ? ? ? ? fos =newFileOutputStream("2.jpg");// ①獲取通道inChannel = fis.getChannel();? ? ? ? ? ? outChannel = fos.getChannel();// ②將通道中的數(shù)據(jù)存入緩沖區(qū)ByteBuffer byteBuffer = ByteBuffer.allocate(1024);// 將通道中的數(shù)據(jù)存入緩沖區(qū)while(inChannel.read(byteBuffer) != -1) {? ? ? ? ? ? ? ? byteBuffer.flip();// 切換讀取數(shù)據(jù)的模式outChannel.write(byteBuffer);? ? ? ? ? ? ? ? byteBuffer.clear();? ? ? ? ? ? }? ? ? ? }catch(IOException e) {? ? ? ? ? ? e.printStackTrace();? ? ? ? }finally{if(inChannel !=null) {try{? ? ? ? ? ? ? ? ? ? inChannel.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }if(outChannel !=null) {try{? ? ? ? ? ? ? ? ? ? outChannel.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }if(fis !=null) {try{? ? ? ? ? ? ? ? ? ? fis.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }if(fos !=null) {try{? ? ? ? ? ? ? ? ? ? fos.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }? ? ? ? }

2.通道之間的傳輸

CREATE_NEW:如果文件不存在就創(chuàng)建,存在就報(bào)錯(cuò)

CREATE:如果文件不存在就創(chuàng)建,存在創(chuàng)建(覆蓋)

FileChannel inChannel =null;? ? ? ? FileChannel outChannel =null;try{? ? ? ? ? ? inChannel = FileChannel.open(Paths.get("hello.txt"), StandardOpenOption.READ);? ? ? ? ? ? outChannel = FileChannel.open(Paths.get("hello2.txt"), StandardOpenOption.READ,StandardOpenOption.WRITE,StandardOpenOption.CREATE_NEW);? ? ? ? ? ? ? ? ? ? ? ? inChannel.transferTo(0, inChannel.size(), outChannel);? ? ? ? }catch(Exception e) {? ? ? ? ? ? e.printStackTrace();? ? ? ? }finally{if(inChannel !=null){try{? ? ? ? ? ? ? ? ? ? inChannel.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }if(outChannel !=null){try{? ? ? ? ? ? ? ? ? ? outChannel.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }? ? ? ? }

3. 使用直接緩沖區(qū)完成內(nèi)存文件的復(fù)制

FileChannel inChannel =null;? ? ? ? FileChannel outChannel =null;try{? ? ? ? ? ? inChannel = FileChannel.open(Paths.get("1.jpg"), StandardOpenOption.READ);? ? ? ? ? ? outChannel = FileChannel.open(Paths.get("x.jpg"), StandardOpenOption.READ,StandardOpenOption.WRITE,StandardOpenOption.CREATE_NEW);? ? ? ? ? ? ? ? ? ? ? ? MappedByteBuffer inMappedBuffer = inChannel.map(MapMode.READ_ONLY,0, inChannel.size());? ? ? ? ? ? MappedByteBuffer outMappedBuffer = outChannel.map(MapMode.READ_WRITE,0, inChannel.size());? ? ? ? ? ? ? ? ? ? ? ? System.out.println(inMappedBuffer.limit());byte[] b =newbyte[inMappedBuffer.limit()];;? ? ? ? ? ? inMappedBuffer.get(b);? ? ? ? ? ? outMappedBuffer.put(b);? ? ? ? ? ? ? ? ? ? }catch(Exception e) {? ? ? ? ? ? e.printStackTrace();? ? ? ? }finally{if(inChannel !=null){try{? ? ? ? ? ? ? ? ? ? inChannel.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }if(outChannel !=null){try{? ? ? ? ? ? ? ? ? ? outChannel.close();? ? ? ? ? ? ? ? }catch(IOException e) {? ? ? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? ? ? }? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? }

2.3 重點(diǎn) NIO-非阻塞IO

個(gè)人認(rèn)為 NIO 最難的兩點(diǎn) 一個(gè)是對(duì)于選擇器和選擇鍵的理解 其次是對(duì)于網(wǎng)絡(luò)通信模型的理解

本章內(nèi)容以防過(guò)長(zhǎng) 只講解 NIO 的使用方法 上述兩點(diǎn)參看下回分解

阻塞IO示例:

//客戶(hù)端@Testpublicvoidclient()throwsIOException{? ? ? ? SocketChannel sChannel = SocketChannel.open(newInetSocketAddress("127.0.0.1",9898));? ? ? ? ? ? ? ? FileChannel inChannel = FileChannel.open(Paths.get("1.jpg"), StandardOpenOption.READ);? ? ? ? ? ? ? ? ByteBuffer buf = ByteBuffer.allocate(1024);while(inChannel.read(buf) != -1){? ? ? ? ? ? buf.flip();? ? ? ? ? ? sChannel.write(buf);? ? ? ? ? ? buf.clear();? ? ? ? }? ? ? ? ? ? ? ? sChannel.shutdownOutput();//接收服務(wù)端的反饋intlen =0;while((len = sChannel.read(buf)) != -1){? ? ? ? ? ? buf.flip();? ? ? ? ? ? System.out.println(newString(buf.array(),0, len));? ? ? ? ? ? buf.clear();? ? ? ? }? ? ? ? ? ? ? ? inChannel.close();? ? ? ? sChannel.close();? ? }//服務(wù)端@Testpublicvoidserver()throwsIOException{? ? ? ? ServerSocketChannel ssChannel = ServerSocketChannel.open();? ? ? ? ? ? ? ? FileChannel outChannel = FileChannel.open(Paths.get("2.jpg"), StandardOpenOption.WRITE, StandardOpenOption.CREATE);? ? ? ? ? ? ? ? ssChannel.bind(newInetSocketAddress(9898));? ? ? ? ? ? ? ? SocketChannel sChannel = ssChannel.accept();? ? ? ? ? ? ? ? ByteBuffer buf = ByteBuffer.allocate(1024);while(sChannel.read(buf) != -1){? ? ? ? ? ? buf.flip();? ? ? ? ? ? outChannel.write(buf);? ? ? ? ? ? buf.clear();? ? ? ? }//發(fā)送反饋給客戶(hù)端buf.put("服務(wù)端接收數(shù)據(jù)成功".getBytes());? ? ? ? buf.flip();? ? ? ? sChannel.write(buf);? ? ? ? ? ? ? ? sChannel.close();? ? ? ? outChannel.close();? ? ? ? ssChannel.close();? ? }

非阻塞IO示例-TCP:

//客戶(hù)端@Testpublicvoidclient()throwsIOException{//1. 獲取通道SocketChannel sChannel = SocketChannel.open(newInetSocketAddress("127.0.0.1",9898));//2. 切換非阻塞模式sChannel.configureBlocking(false);//3. 分配指定大小的緩沖區(qū)ByteBuffer buf = ByteBuffer.allocate(1024);//4. 發(fā)送數(shù)據(jù)給服務(wù)端Scanner scan =newScanner(System.in);while(scan.hasNext()){? ? ? ? ? ? String str = scan.next();? ? ? ? ? ? buf.put((newDate().toString() +"\n"+ str).getBytes());? ? ? ? ? ? buf.flip();? ? ? ? ? ? sChannel.write(buf);? ? ? ? ? ? buf.clear();? ? ? ? }//5. 關(guān)閉通道sChannel.close();? ? }//服務(wù)端@Testpublicvoidserver()throwsIOException{//1. 獲取通道ServerSocketChannel ssChannel = ServerSocketChannel.open();//2. 切換非阻塞模式ssChannel.configureBlocking(false);//3. 綁定連接ssChannel.bind(newInetSocketAddress(9898));//4. 獲取選擇器Selector selector = Selector.open();//5. 將通道注冊(cè)到選擇器上, 并且指定“監(jiān)聽(tīng)接收事件”ssChannel.register(selector, SelectionKey.OP_ACCEPT);//6. 輪詢(xún)式的獲取選擇器上已經(jīng)“準(zhǔn)備就緒”的事件while(selector.select() >0){//7. 獲取當(dāng)前選擇器中所有注冊(cè)的“選擇鍵(已就緒的監(jiān)聽(tīng)事件)”Iterator it = selector.selectedKeys().iterator();while(it.hasNext()){//8. 獲取準(zhǔn)備“就緒”的是事件SelectionKey sk = it.next();//9. 判斷具體是什么事件準(zhǔn)備就緒if(sk.isAcceptable()){//10. 若“接收就緒”,獲取客戶(hù)端連接SocketChannel sChannel = ssChannel.accept();//11. 切換非阻塞模式sChannel.configureBlocking(false);//12. 將該通道注冊(cè)到選擇器上sChannel.register(selector, SelectionKey.OP_READ);? ? ? ? ? ? ? ? }elseif(sk.isReadable()){//13. 獲取當(dāng)前選擇器上“讀就緒”狀態(tài)的通道SocketChannel sChannel = (SocketChannel) sk.channel();//14. 讀取數(shù)據(jù)ByteBuffer buf = ByteBuffer.allocate(1024);intlen =0;while((len = sChannel.read(buf)) >0){? ? ? ? ? ? ? ? ? ? ? ? buf.flip();? ? ? ? ? ? ? ? ? ? ? ? System.out.println(newString(buf.array(),0, len));? ? ? ? ? ? ? ? ? ? ? ? buf.clear();? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? }//15. 取消選擇鍵 SelectionKeyit.remove();? ? ? ? ? ? }? ? ? ? }? ? }

非阻塞IO示例-UDP:

@Testpublicvoidsend()throwsIOException{? ? ? ? DatagramChannel dc = DatagramChannel.open();? ? ? ? ? ? ? ? dc.configureBlocking(false);? ? ? ? ? ? ? ? ByteBuffer buf = ByteBuffer.allocate(1024);? ? ? ? ? ? ? ? Scanner scan =newScanner(System.in);while(scan.hasNext()){? ? ? ? ? ? String str = scan.next();? ? ? ? ? ? buf.put((newDate().toString() +":\n"+ str).getBytes());? ? ? ? ? ? buf.flip();? ? ? ? ? ? dc.send(buf,newInetSocketAddress("127.0.0.1",9898));? ? ? ? ? ? buf.clear();? ? ? ? }? ? ? ? ? ? ? ? dc.close();? ? }@Testpublicvoidreceive()throwsIOException{? ? ? ? DatagramChannel dc = DatagramChannel.open();? ? ? ? ? ? ? ? dc.configureBlocking(false);? ? ? ? ? ? ? ? dc.bind(newInetSocketAddress(9898));? ? ? ? ? ? ? ? Selector selector = Selector.open();? ? ? ? ? ? ? ? dc.register(selector, SelectionKey.OP_READ);while(selector.select() >0){? ? ? ? ? ? Iterator it = selector.selectedKeys().iterator();while(it.hasNext()){? ? ? ? ? ? ? ? SelectionKey sk = it.next();if(sk.isReadable()){? ? ? ? ? ? ? ? ? ? ByteBuffer buf = ByteBuffer.allocate(1024);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? dc.receive(buf);? ? ? ? ? ? ? ? ? ? buf.flip();? ? ? ? ? ? ? ? ? ? System.out.println(newString(buf.array(),0, buf.limit()));? ? ? ? ? ? ? ? ? ? buf.clear();? ? ? ? ? ? ? ? }? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? it.remove(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?歡迎工作一到五年的Java工程師朋友們加入Java群:?891219277

群內(nèi)提供免費(fèi)的Java架構(gòu)學(xué)習(xí)資料(里面有高可用、高并發(fā)、高性能及分布式、Jvm性能調(diào)優(yōu)、Spring源碼,MyBatis,Netty,Redis,Kafka,Mysql,Zookeeper,Tomcat,Docker,Dubbo,Nginx等多個(gè)知識(shí)點(diǎn)的架構(gòu)資料)合理利用自己每一分每一秒的時(shí)間來(lái)學(xué)習(xí)提升自己,不要再用"沒(méi)有時(shí)間“來(lái)掩飾自己思想上的懶惰!趁年輕,使勁拼,給未來(lái)的自己一個(gè)交代!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,546評(píng)論 6 533
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,570評(píng)論 3 418
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人,你說(shuō)我怎么就攤上這事。” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 176,505評(píng)論 0 376
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我,道長(zhǎng),這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 63,017評(píng)論 1 313
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,786評(píng)論 6 410
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 55,219評(píng)論 1 324
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,287評(píng)論 3 441
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 42,438評(píng)論 0 288
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,971評(píng)論 1 335
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,796評(píng)論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,995評(píng)論 1 369
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,540評(píng)論 5 359
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,230評(píng)論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 34,662評(píng)論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 35,918評(píng)論 1 286
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 51,697評(píng)論 3 392
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,991評(píng)論 2 374

推薦閱讀更多精彩內(nèi)容

  • 一、Socket通道 新的socket通道類(lèi)可以運(yùn)行非阻塞模式并且是可選擇的。這兩個(gè)性能可以激活大程序(如網(wǎng)絡(luò)服務(wù)...
    Java架構(gòu)師筆記閱讀 2,475評(píng)論 0 3
  • JAVA NIO基礎(chǔ) ...
    文思li閱讀 628評(píng)論 0 3
  • Java NIO提供了與標(biāo)準(zhǔn)IO不同的IO工作方式: Channels and Buffers(通道和緩沖區(qū)):標(biāo)...
    Java面試指南閱讀 2,456評(píng)論 0 2
  • 前言: 之前的文章《Java文件IO常用歸納》主要寫(xiě)了Java 標(biāo)準(zhǔn)IO要注意的細(xì)節(jié)和技巧,由于網(wǎng)上各種學(xué)習(xí)途徑,...
    androidjp閱讀 2,914評(píng)論 0 22
  • 原文 先來(lái)回顧一下傳統(tǒng)的IO模式的,將傳統(tǒng)的IO模式的相關(guān)類(lèi)理清楚(因?yàn)镮O的類(lèi)很多)。 但是,發(fā)現(xiàn)在整理的過(guò)程已...
    baby_honour閱讀 1,440評(píng)論 2 35