Java NIO Tutorial

 
 

Jakob Jenkov
Last update: 2014-06-25

Java NIO (New IO) is an alternative IO API for Java (from Java 1.4), meaning alternative to the standardJava IO and Java Networking API's. Java NIO offers a different way of working with IO than the standard IO API's.

NIO是一个可供替代的 io API, 可以用来代替原来的IO 和网络 API。

Java NIO: Channels and Buffers

In the standard IO API you work with byte streams and character streams. In NIO you work with channels and buffers. Data is always read from a channel into a buffer, or written from a buffer to a channel.

标准IO api 是用 字节流和 字符流工作;NIO是用 通道 Channel和缓冲 buffer 工作,数据是从Channel读到buffer,从buffer写到Channel

Java NIO: Non-blocking IO

nio是非阻塞io,thread让Channel读数据到buffer,然后线程可以做其他事,读完了可以继续处理他。

Java NIO enables you to do non-blocking IO. For instance, a thread can ask a channel to read data into a buffer. While the channel reads data into the buffer, the thread can do something else. Once data is read into the buffer, the thread can then continue processing it. The same is true for writing data to channels.

Java NIO: Selectors

一个selector可以模拟操作多个Channel的处理数据。

Java NIO contains the concept of "selectors". A selector is an object that can monitor multiple channels for events (like: connection opened, data arrived etc.). Thus, a single thread can monitor multiple channels for data.

How all this works is explained in more detail in the next text in this series - the Java NIO overview.

Java NIO Tutorial的更多相关文章

  1. The Rox Java NIO Tutorial

    FQ之后访问 http://rox-xmlrpc.sourceforge.net/niotut/

  2. 快学Java NIO 续篇

    可以先看Java NIO的整体介绍,这篇接着说以下内容,<快学Java NIO>续篇 FileChannel SocketChannel ServerSocketChannel Java ...

  3. 快学Java NIO

    Java NIO Tutorial 地址:http://tutorials.jenkov.com/java-nio/index.html Java NIO系列教程译文地址:http://ifeve.c ...

  4. Java NIO 完全学习笔记(转)

    本篇博客依照 Java NIO Tutorial翻译,算是学习 Java NIO 的一个读书笔记.建议大家可以去阅读原文,相信你肯定会受益良多. 1. Java NIO Tutorial Java N ...

  5. Java NIO 核心组件学习笔记

    背景知识 同步.异步.阻塞.非阻塞 首先,这几个概念非常容易搞混淆,但NIO中又有涉及,所以总结一下[1]. 同步:API调用返回时调用者就知道操作的结果如何了(实际读取/写入了多少字节). 异步:相 ...

  6. Java NIO Overview

    Java NIO Overview Channels and Buffers Selectors   Jakob JenkovLast update: 2014-06-23

  7. Java NIO 学习笔记(一)----概述,Channel/Buffer

    目录: Java NIO 学习笔记(一)----概述,Channel/Buffer Java NIO 学习笔记(二)----聚集和分散,通道到通道 Java NIO 学习笔记(三)----Select ...

  8. Five ways to maximize Java NIO and NIO.2--reference

    Java NIO -- the New Input/Output API package-- was introduced with J2SE 1.4 in 2002. Java NIO's purp ...

  9. Java NIO Files

    Java NIO Files Files.exists() Files.createDirectory() Files.copy() Overwriting Existing Files Files. ...

随机推荐

  1. spring揭密学习笔记

    spring揭密学习笔记 spring揭密学习笔记(1) --spring的由来 spring揭密学习笔记(2)-spring ioc容器:IOC的基本概念

  2. (二)apache atlas配置和运行

    上一篇文章,我们已经构建出了altas的安装包,所以我们继续使用安装包配置和运行atlas 首先解压atlas压缩包,授予bin目录下的执行权限 1.默认启动atlas cd atlas/bin/ p ...

  3. mysql5.7-windows安装配置

    sonar要求mysql5.6版本以上,所以安装一下最新的mysql5.7 采用相对名路径和命令行启动,这样是为了方便迁移.也提供了加入服务的指令,但没有进行测试 解压mysql的zip压缩包 解压后 ...

  4. hive之窗口函数

    窗口函数 1.相关函数说明 COVER():指定分析函数工作的数据窗口大小,这个数据窗口大小可能会随着行的变而变化 CURRENT ROW:当前行 n PRECEDING:往前n行数据 n FOLLO ...

  5. 实战ELK(1) 安装ElasticSearch

    第一步:环境 linux 系统 Java 1.8.0  elasticsearch-6.5.1 第二步:下载 2.1 JDK:https://mirrors.aliyun.com/centos/7.5 ...

  6. 禁用firefox 56自动更新

    firefox 56支持旧式扩展,这很重要! 它却自动更新,简单地关了也不行,很是牛氓! ========== -备份C:\Users\用户名\AppData\Roaming\Mozilla\Fire ...

  7. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'test'

    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'test' 报错原因是:MySQL数据库没有 ...

  8. USB之HID类Set_Report Request[调试手记1]

    请翻开<Device Class Definition for Human Interface Devices (HID) Version 1.11 >7.2.2 Set_Report R ...

  9. Executors.newSingleThreadScheduledExecutor();线程池中放入多个线程问题

    转自:https://blog.csdn.net/u012062455/article/details/78247234/

  10. clientdataset.open 报错 Name not unique in this context

    clientdataset.open 报错  Name not unique in this context clientdataset有一些自定义字段,clientdataset绑定了adoquer ...