Java NIO總結(jié)

NIO是Java 1.4開始引入的,目的是替代標(biāo)準(zhǔn)IO,它采用了與標(biāo)準(zhǔn)IO完全不同的設(shè)計(jì)模式和工作方式,這里就來總結(jié)一下。

1.Buffer

正如他的名字,就是一個(gè)緩存,實(shí)際上是內(nèi)存的一塊區(qū)域,它是NIO體系的重要組成部分,主要和通道進(jìn)行交互。 Buffer本身是一個(gè)抽象類,它有以下幾個(gè)子類:
ByteBuffer
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
ShortBuffer
根據(jù)緩存的數(shù)據(jù)類型不同創(chuàng)建的不同子類,大致功能都類似,我們不一個(gè)一個(gè)介紹,只介紹Buffer的關(guān)鍵點(diǎn)。

Buffer的使用一般如下:將數(shù)據(jù)寫入buffer,準(zhǔn)備從buffer中讀數(shù)據(jù),讀取數(shù)據(jù),清空buffer。下面先簡(jiǎn)單演示一下然后再解釋:

    public static void main(String[] args) throws IOException {
        try (RandomAccessFile file = new RandomAccessFile("file/test.txt","rw");
             FileChannel channel = file.getChannel()){
            ByteBuffer buffer = ByteBuffer.allocate(5);
            int len;
            while((len = channel.read(buffer))!=-1){
                buffer.flip();
                while (buffer.hasRemaining())
                    System.out.println((char)buffer.get());
                buffer.compact();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

先看構(gòu)造,Buffer的子類也都是抽象類,不能直接實(shí)例化,都需要調(diào)用靜態(tài)方法生成,可以看源碼,調(diào)用不同的靜態(tài)方法實(shí)例化不同的實(shí)現(xiàn)類。以ByteBuffer為例,可以這樣實(shí)例化:

allocate(int capacity) //分配一個(gè)大小為capacity的字節(jié)數(shù)組作為緩沖,但是在堆中
allocateDirect(int capacity) //和上面類似,不過直接借助系統(tǒng)在內(nèi)存中創(chuàng)建,速度較快,但消耗性能
wrap(byte[] array) //直接從外部指定一個(gè)數(shù)組,不適用默認(rèn)創(chuàng)建的,但是雙方一方改動(dòng)就會(huì)影響另一方
wrap(byte[] array, int offset, int length) //和上面一個(gè)一樣,但是能指定偏移量和長(zhǎng)度

我們獲得一個(gè)Buffer實(shí)例后就可以使用,首先向buffer中寫東西需要channel配合,調(diào)用read方法即可。之后在讀之前需要準(zhǔn)備一下,從代碼看就是調(diào)用flip方法,這個(gè)方法有什么作用呢?從文檔上看,就是將limit設(shè)置為position,然后將position 置零。這樣有什么用呢?下面就來介紹一下buffer的幾個(gè)成員變量:capacity,limit,position。

capacity就是一個(gè)buffer的固定大小,表示他的容量
position表示當(dāng)前指針的位置,也就是當(dāng)前讀或?qū)懙降奈恢?br> limit這個(gè)值在寫模式下表示最多能寫多少,寫模式下等于capacity。讀模式下表示能讀到多少,調(diào)用flip將limit等于position,表示最多能讀到之前寫入的所有內(nèi)容

看flip的實(shí)現(xiàn)也很好理解,如下:

    public final Buffer flip() {
        limit = position;
        position = 0;
        mark = -1;
        return this;
    }

剛才是準(zhǔn)備讀數(shù)據(jù),下面就是從中讀了,buffer有一系列g(shù)et方法,和流的read方法類似。既然有g(shù)et就有put方法,除了上面和channel配合寫入東西,還可以用一系列put方法寫入。讀之前可以判斷一下是否還有數(shù)據(jù):hasRemaining();讀完之后為了使下次還能用,需要清空buffer,可以用clear方法或者compact方法。可以看一下他們的實(shí)現(xiàn):

    public final Buffer clear() {
        position = 0;
        limit = capacity;
        mark = -1;
        return this;
    }
    public ByteBuffer compact() {
        System.arraycopy(hb, ix(position()), hb, ix(0), remaining());
        position(remaining());
        limit(capacity());
        discardMark();
        return this;
    }

clear方法很清晰,就是將幾個(gè)游標(biāo)歸為為原始狀態(tài)。compact也是設(shè)置幾個(gè)游標(biāo)位置,不過有點(diǎn)特殊,remaining方法是獲取剩余數(shù)據(jù)數(shù)量就是limit - position,然后將該值賦給position,然后將capacity賦值給limit。他和clear的區(qū)別就是在position上的處理。但是,如果我們已經(jīng)將buffer內(nèi)容讀完,這時(shí)limit = position,那么 position(remaining())的效果就是position = limit - position = 0.這時(shí)compact方法效果等于clear。否則雖然也可以繼續(xù)寫內(nèi)容進(jìn)去,但容量減少,但好處是未讀的數(shù)據(jù)以后可以繼續(xù)讀。

再來看其他方法:

    public final Buffer rewind() {
        position = 0;
        mark = -1;
        return this;
    }

rewind是將position 置零,也就是buffer中內(nèi)容可以重新讀取。

    public final Buffer mark() {
        mark = position;
        return this;
    }
    public final Buffer reset() {
        int m = mark;
        if (m < 0)
            throw new InvalidMarkException();
        position = m;
        return this;
    }

mark和reset是配合使用的。mark標(biāo)記一個(gè)位置,reset使游標(biāo)回到這個(gè)位置。mark成員變量初始為-1.所以不要沒有調(diào)用mark方法就去調(diào)用reset。

可以看到buffer的主要操作就是針對(duì)幾個(gè)指針的,畢竟他是依賴于數(shù)組實(shí)現(xiàn)的。

2.Channel

Channel用來實(shí)現(xiàn)通道的概念,他類似于流,但是不能直接操作數(shù)據(jù),需要借助于Buffer,它本身是一個(gè)接口,一般有以下幾個(gè)重要實(shí)現(xiàn):
FileChannel
DatagramChannel
SocketChannel
ServerSocketChannel

2.1 FileChannel

FileChannel是一個(gè)用于讀寫操作文件的channel。首先看怎么獲得實(shí)例化對(duì)象,F(xiàn)ileChannel也是一個(gè)抽象類,所以不能通過構(gòu)造獲得。一般獲得的途徑有,RandomAccessFile、FileOutputStream、FileInputStream等一些類的getChannel()方法,如上文中示例。

另外在Java 1.7 中提供了幾個(gè)靜態(tài)的open方法用來直接打開或創(chuàng)建文件獲取Channel:

    public static void main(String[] args) throws IOException {
        try (FileChannel channel = FileChannel.open(Paths.get("file/test.txt"), StandardOpenOption.READ)){
            ByteBuffer buffer = ByteBuffer.allocate(5);
            int len;
            while((len = channel.read(buffer))!=-1){
                buffer.flip();
                while (buffer.hasRemaining())
                    System.out.println((char)buffer.get());
                buffer.compact();
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }

Channel是不能直接讀數(shù)據(jù)的,需要借助于buffer,同樣寫內(nèi)容也是要借助于buffer,下面演示一下傳統(tǒng)的復(fù)制文件。

    public static void main(String[] args) throws IOException {
        try (FileChannel readChannel = FileChannel.open(Paths.get("file/test.png"), StandardOpenOption.READ)){
            FileChannel writeChannel = FileChannel.open(Paths.get("file/copy.png"), StandardOpenOption.READ,StandardOpenOption.WRITE,StandardOpenOption.CREATE);
            ByteBuffer buffer = ByteBuffer.allocate(1024);
            while (readChannel.read(buffer)!=-1){
                buffer.flip();
                while (buffer.hasRemaining())
                    writeChannel.write(buffer);
                buffer.clear();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

有一點(diǎn)需要注意的是,有時(shí)并不能保證把整個(gè)buffer的內(nèi)容寫入,為了嚴(yán)謹(jǐn)起見,需要循環(huán)判斷buffer中是否有內(nèi)容未寫入。

除了上面?zhèn)鹘y(tǒng)的寫法,channel還有自己特有的傳輸方法:

        try (FileChannel readChannel = FileChannel.open(Paths.get("file/test.png"), StandardOpenOption.READ)){
            FileChannel writeChannel = FileChannel.open(Paths.get("file/copy.png"), StandardOpenOption.READ,StandardOpenOption.WRITE,StandardOpenOption.CREATE);
            //以下兩句話效果一樣
            //writeChannel.transferFrom(readChannel,0,readChannel.size());
            readChannel.transferTo(0,readChannel.size(),writeChannel);
        }catch (Exception e){
            e.printStackTrace();
        }

transferFrom和transferTo都是把一個(gè)channel的內(nèi)容傳輸?shù)搅硪粋€(gè),但是注意兩個(gè)方法的區(qū)別,即方向性。

上面示例用到了size()方法,是用來獲取所關(guān)聯(lián)文件的大小。

position()和position(long)方法用來獲取指針位置和設(shè)置指針位置。設(shè)置position是可以將指針設(shè)置到文件結(jié)束符之后的,但是中間會(huì)有空洞。

truncate(long)方法可一截取一個(gè)文件并返回FileChannel,從文件開始截取到指定位置。

2.2 DatagramChannel

DatagramChannel是Java UDP通信中傳輸數(shù)據(jù)的通道。關(guān)于Java中傳統(tǒng)UDP的實(shí)現(xiàn)見這里,下面簡(jiǎn)單用DatagramChannel實(shí)現(xiàn)一下UDP通信
服務(wù)端

public class UDPService {
    public static final String SERVICE_IP = "127.0.0.1";

    public static final int SERVICE_PORT = 10101;

    public static void main(String[] args) {
        UDPService service = new UDPService();
        service.startService(SERVICE_IP,SERVICE_PORT);
    }

    private void startService(String ip, int port){
        try (DatagramChannel channel = DatagramChannel.open()){
            channel.bind(new InetSocketAddress(ip,port));
            while (true){
                ByteBuffer buffer = ByteBuffer.allocate(1024);
                SocketAddress socketAddress = channel.receive(buffer);
                String receive = new String(buffer.array(),"UTF-8").trim();
                System.out.println("address: " + socketAddress.toString()+ " msg: "+ receive);
                buffer.clear();
                buffer.put((receive + "hello world").getBytes());
                buffer.flip();
                channel.send(buffer,socketAddress);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

客戶端

public class UDPClient {

    public static void main(String[] args){
        UDPClient client = new UDPClient();
        Scanner scanner = new Scanner(System.in);
        while(true){
            String msg = scanner.nextLine();
            if("##".equals(msg))
                break;
            System.out.println(client.sendAndReceive(UDPService.SERVICE_IP,UDPService.SERVICE_PORT,msg));
        }
    }

    private String sendAndReceive(String serviceIp, int servicePort, String msg) {
        try (DatagramChannel channel = DatagramChannel.open()){
            ByteBuffer buffer = ByteBuffer.allocate(1024);
            buffer.put(msg.getBytes());
            System.out.println(buffer.position());
            buffer.flip();
            SocketAddress address = new InetSocketAddress(serviceIp,servicePort);
            System.out.println( channel.send(buffer,address));
            buffer.clear();
            SocketAddress socketAddress = channel.receive(buffer);
            return "address: " + socketAddress.toString()+ " msg: "+ new String(buffer.array(),"UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "null";
    }
}

一般獲得一個(gè)DatagramChannel 需要使用靜態(tài)方法open,DatagramChannel 也是配合buffer使用的。之后服務(wù)端需要綁定一個(gè)地址和端口。接下來就可以收發(fā)數(shù)據(jù)了,收用receive方法,返回發(fā)送方的地址信息,發(fā)生使用send方法,返回成功發(fā)生的字節(jié)數(shù)。

有一點(diǎn)特別重要,由于是配合buffer操作,無論是客戶端還是服務(wù)端,在發(fā)送前都需要調(diào)用flip方法,否則發(fā)送的都是空數(shù)據(jù)(因?yàn)槎际菑膒osition到limit,flip之前position是當(dāng)前寫的位置,limit為capacity)。還有一點(diǎn),在接受時(shí),由于不知道buffer中有效字節(jié)數(shù),所以limit為capacity,直觀的看就是轉(zhuǎn)為字符串時(shí)末尾有大量空內(nèi)容,需要trim一下。

默認(rèn)情況下是阻塞的,也可以設(shè)置為非阻塞的,channel.configureBlocking(true);,此時(shí)receive方法會(huì)立刻返回,可能為null。channel也有connect方法,但是UDP是非連接的,所以只是綁定一個(gè)遠(yuǎn)端地址,收發(fā)智能從指定地址來。connect之后就可以用read或者write收發(fā)數(shù)據(jù)。

2.3 SocketChannel 與 ServerSocketChannel

這兩類是和Socket與 ServerSocket對(duì)應(yīng)的兩個(gè)雷,也是專為TCP通信設(shè)計(jì)的,ServerSocketChannel代表服務(wù)端,SocketChannel 代表一個(gè)連接。關(guān)于Java的傳統(tǒng)TCP實(shí)現(xiàn)見這里,下面簡(jiǎn)單實(shí)現(xiàn)一下TCP通信
服務(wù)端:

public class TCPService {
    public static final String SERVICE_IP = "127.0.0.1";

    public static final int SERVICE_PORT = 10101;

    public static void main(String[] args) {
        TCPService service = new TCPService();
        service.startService();
    }
    private void startService(){
        try (ServerSocketChannel service = ServerSocketChannel.open()){
            service.bind(new InetSocketAddress(SERVICE_IP,SERVICE_PORT));
            while (true){
                SocketChannel channel = service.accept();
                ByteBuffer buffer = ByteBuffer.allocate(1024);
                StringBuilder msg = new StringBuilder();
                while ((len = channel.read(buffer)) > 0) {
                    receive.append(new String(buffer.array(), 0, len));
                    buffer.clear();
                }
                System.out.println("address: " + channel.getRemoteAddress().toString() + " msg: " + msg.toString());

                buffer.clear();
                buffer.put((msg + "hello world").getBytes());
                buffer.flip();
                while (buffer.hasRemaining())
                    channel.write(buffer);
                channel.shutdownOutput();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

客戶端

public class TCPClient {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        TCPClient client = new TCPClient();
        while(true){
            System.out.println(client.sendAndReceive(TCPService.SERVICE_IP,TCPService.SERVICE_PORT,scanner.nextLine()));
        }
    }

    private String sendAndReceive(String address,int port,String msg){
        try (SocketChannel channel = SocketChannel.open()){
            channel.connect(new InetSocketAddress(address,port));
            ByteBuffer buffer = ByteBuffer.allocate(1024);
            buffer.put(msg.getBytes());
            buffer.flip();
            while (buffer.hasRemaining())
                channel.write(buffer);
            channel.shutdownOutput();
            buffer.clear();

            StringBuilder receive = new StringBuilder();
            int len = 0;
            while ((len = channel.read(buffer)) > 0) {
                receive.append(new String(buffer.array(), 0, len));
                buffer.clear();
            }
            return "address: " + channel.getRemoteAddress().toString() + " msg: " + receive.toString();
        }catch (Exception e){
            e.printStackTrace();
        }
        return "null";
    }
}

同樣都是利用open獲取一個(gè)示例,服務(wù)端要綁定地址和端口,然后監(jiān)聽連接,客戶端只需去連接服務(wù)端即可。同樣的都可以設(shè)置為非阻塞的,收發(fā)數(shù)據(jù)使用read和write方法。需要注意的還是buffer操作問題以及即使關(guān)流或者做控制就行。

3.Selector

Selector 可以同時(shí)監(jiān)控多個(gè)Channel 的 IO 狀況,也就是說,利用 Selector可使一個(gè)單獨(dú)的線程管理多個(gè) Channel,selector 是非阻塞 IO 的核心。簡(jiǎn)單示例
客戶端

public class TCPClient {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        TCPClient client = new TCPClient();
        while(true){
            client.sendAndReceive(TCPService.SERVICE_IP,TCPService.SERVICE_PORT,scanner.nextLine());
        }
    }

    private void sendAndReceive(String address,int port,String msg){
        try (SocketChannel channel = SocketChannel.open()){
            channel.connect(new InetSocketAddress(address, port));
            ByteBuffer buf = ByteBuffer.allocate(1024);
            channel.configureBlocking(false);
            buf.put((new Date() + ":" + msg).getBytes());
            buf.flip();
            channel.write(buf);
            buf.clear();
            channel.shutdownOutput();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

服務(wù)端

public class TCPService {
    public static final String SERVICE_IP = "127.0.0.1";

    public static final int SERVICE_PORT = 10101;

    private String msg;

    public static void main(String[] args) {
        TCPService service = new TCPService();
        service.startService();
    }
    private void startService(){
        try (ServerSocketChannel service = ServerSocketChannel.open()){
            service.bind(new InetSocketAddress(SERVICE_IP,SERVICE_PORT));
            service.configureBlocking(false);
            Selector selector = Selector.open();
            service.register(selector, SelectionKey.OP_ACCEPT);
            while (selector.select() > 0) {
                Iterator<SelectionKey> it = selector.selectedKeys().iterator();
                while (it.hasNext()) {
                    SelectionKey key = it.next();
                    if (key.isAcceptable()) {
                        System.out.println("isAcceptable");
                        SocketChannel sc = service.accept();
                        sc.configureBlocking(false);
                        sc.register(selector, SelectionKey.OP_READ );
                    } else if (key.isReadable()) {
                        System.out.println("isReadable");
                        SocketChannel channel = (SocketChannel) key.channel();
                        ByteBuffer buf = ByteBuffer.allocate(1024);
                        int len = 0;
                        StringBuilder sb = new StringBuilder();
                        while ((len = channel.read(buf)) > 0) {
                            sb.append(new String(buf.array(), 0, len));
                            buf.clear();
                        }
                        System.out.println(sb.toString());
                        channel.close();
                    }
                    it.remove();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}

主要是服務(wù)端的應(yīng)用,基本流程就是先利用open()方法獲取一個(gè)Selector ,設(shè)置ServerSocketChannel 為非阻塞的,之后注冊(cè)事件,一般有以下幾種

SelectionKey.OP_CONNECT
SelectionKey.OP_ACCEPT
SelectionKey.OP_READ
SelectionKey.OP_WRITE

之后調(diào)用select()返回就緒通道數(shù),然后根據(jù)時(shí)間類型執(zhí)行具體操作即可。

4.Pipe

傳統(tǒng)IO為我們提供了線程間通信的類,PipedInputStream與PipedOutputStream。NIO作為IO的替代者,自然也有線程通信的方法,就是Pipe,使用起來很簡(jiǎn)單,如下:

public class Receiver extends Thread{
    private Pipe pipe;

    public void setPipe(Pipe pipe){
        this.pipe = pipe;
    }
    @Override
    public void run() {
        super.run();
        try (Pipe.SourceChannel channel = pipe.source()){
            ByteBuffer buf = ByteBuffer.allocate(1024);
            int len = 0;
            StringBuilder sb = new StringBuilder();
            while((len = channel.read(buf))!=-1){
                sb.append(new String(buf.array(),0,len));
                buf.clear();
            }
            System.out.println(sb.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
public class Sender extends Thread{
    private Pipe pipe;

    public void setPipe(Pipe pipe){
        this.pipe = pipe;
    }
    @Override
    public void run() {
        super.run();
        try (Pipe.SinkChannel channel = pipe.sink()){
            ByteBuffer buffer = ByteBuffer.allocate(1024);
            buffer.put("hello world".getBytes());
            buffer.flip();
            while (buffer.hasRemaining())
                channel.write(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
    public static void main(String[] args) throws IOException {
        Receiver receiver = new Receiver();
        Sender sender = new Sender();
        Pipe pipe = Pipe.open();
        receiver.setPipe(pipe);
        sender.setPipe(pipe);
        receiver.start();
        sender.start();
    }

Pipe只是一個(gè)管理者,收發(fā)數(shù)據(jù)還是通過兩個(gè)通道:SinkChannel 和SourceChannel 。都是單項(xiàng)的,SinkChannel 負(fù)責(zé)寫數(shù)據(jù),SourceChannel 負(fù)責(zé)收數(shù)據(jù)。

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

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