`
kylinsoong
  • 浏览: 236140 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

JDK Source Code & java.nio

阅读更多

java.nio is very useful and a pretty good supplement for java.io, today's series I will exploring java.nio key interface and class in below figures:



 Channel: A channel represents an open connection to an entity such as a hardware device, a file, a network socket, or a program component that is capable of performing one or more distinct I/O operations, for example reading or writing. A channel is either open or closed.  A channel is open upon creation, and once closed it remains closed. Once a channel is closed, any attempt to invoke an I/O operation upon it will cause a ClosedChannelException to be thrown.  Whether or not a channel is open may be tested by invoking its isOpen method.

 

SelectableChannel: A selectable channel is either in blocking mode or in non-blocking mode. In blocking mode, every I/O operation invoked upon the channel will block until it completes. In non-blocking mode an I/O operation will never block and may transfer fewer bytes than were requested. Newly-created selectable channels are always in blocking mode. Non-blocking mode is most useful in conjunction with selector-based multiplexing.

 

ReadableByteChannel: A channel that can read bytes. Only one read operation upon a readable channel may be in progress at any given time.  If one thread initiates a read operation upon a channel then any other thread that attempts to initiate another read operation will block until the first operation is complete.  Whether or not other kinds of I/O operations may proceed concurrently with a read operation depends upon the type of the channel.

 

WritableByteChannel: A channel that can write bytes. Only one write operation upon a writable channel may be in progress at any given time.  If one thread initiates a write operation upon a channel then any other thread that attempts to initiate another write operation will block until the first operation is complete.  Whether or not other kinds of I/O operations may proceed concurrently with a write operation depends upon the type of the channel.

 

ScatteringByteChannel: A channel that can read bytes into a sequence of buffers. A scattering read operation reads, in a single invocation, a sequence of bytes into one or more of a given sequence of buffers. Scattering reads are often useful when implementing network protocols or file formats that, for example, group data into segments consisting of one or more fixed-length headers followed by a variable-length body.

 

GatheringByteChannel: A channel that can write bytes from a sequence of buffers. A gathering write operation writes, in a single invocation, a sequence of bytes from one or more of a given sequence of buffers. Gathering writes are often useful when implementing network protocols or file formats that, for example, group data into segments consisting of one or more fixed-length headers followed by a variable-length body.

 

ByteChannel: A interface extends ReadableByteChannel, WritableByteChannel that can read and write bytes. This interface simply unifies ReadableByteChannel and WritableByteChannel, it does not specify any new operations. 

 

AbstractSelectableChannel: Base implementation class for selectable channels. This class defines methods that handle the mechanics of channel registration, deregistration, and closing. It maintains the current blocking mode of this channel as well as its current set of selection keys. It performs all of the synchronization required to implement the SelectableChannel specification. Implementations of the abstract protected methods defined in this class need not synchronize against other threads that might be engaged in the same operations.

 

ServerSocketChannel: A selectable channel for stream-oriented listening sockets. Server-socket channels are not a complete abstraction of listening network sockets.  Binding and the manipulation of socket options must be done through an associated java.net.ServerSocket object obtained by invoking the socket() method.

 

SocketChannel: A selectable channel for stream-oriented connecting sockets. A socket channel is created by invoking one of the open methods of this class.  A newly-created socket channel is open but not yet connected.  An attempt to invoke an I/O operation upon an unconnected channel will cause a NotYetConnectedException to be thrown. A socket channel can be connected by invoking its connect method; once connected, a socket channel remains connected until it is closed. Whether or not a socket channel is connected may be determined by invoking its isConnected method. 

 

FileChannel: A channel for reading, writing, mapping, and manipulating a file. A file channel has a current position within its file which can be both position(). The file itself contains a variable-length sequence of bytes that can be read and written and whose current size can be queried. The size of the file increases when bytes are written beyond its current size; the size of the file decreases when it is truncated. The file may also have some associated metadata such as access permissions, content type, and last-modification time; this class does not define methods for metadata access. 

  • 大小: 12 KB
0
1
分享到:
评论

相关推荐

    JDK1.7 之java.nio.file.Files 读取文件仅需一行代码实现

    下面小编就为大家分享一篇JDK1.7 之java.nio.file.Files 读取文件仅需一行代码实现,具有很好的参考价值,希望对大家有所帮助

    bcprov-jdk15on-1.54.jar bcprov-ext-jdk15on-1.54.jar下载

    2.将下载的两个JAR文件复制到:JDK安装目录\jre\lib\ext下,例如我的就是D:\Program Files (x86)\java\JDK1.6\jre\lib\ext 3.打开java.security文件:在JDK安装目录\jre\lib\security下的java.security文件。

    java.io:clojure.java.io 的 JK7 java.nio.file.Path 兼容性

    依赖: [me.moocar/java.io " 0.1.0 " ]用法是 JDK7 中引入的文件路径的抽象。 这个库提供了和 Paths 之间的兼容性。 下面的示例用法( require 'me.moocar.java.io)( require '[clojure.java.io :as jio])( import ...

    bcprov-ext-jdk15on-1.54.jar和bcprov-jdk15on-1.54.jar压缩文件

    bcprov-ext-jdk15on-1.54.jar和bcprov-jdk15on-1.54.jar压缩文件

    JDK1.8下载 : jdk_8.0.1310.11_64.zip

    JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具. JDK是学好Java的第一步。不管是你要学习java...

    Wrox.Professional.Java.JDK.6.Edition.Jan.2007.rar

    Wrox.Professional.Java.JDK.6.Edition.Jan.2007.rar

    dirwatch:Clojure目录观察程序,包装了JDK 7 java.nio.file.WatchService

    类似于t望塔(但使用JDK 7异步通知机制而不是轮询) 与ojo相似(但更简单,允许无限制的观察者和目录递归) 安装 将以下依赖项添加到您的project.clj文件中 用法 ( require '[juxt.dirwatch :refer ( watch-dir )...

    java.nio demo

    Java的IO操作集中在java.io这个包中,是基于流的同步(blocking)API。对于大多数应用来说,这样...从JDK 1.4起,NIO API作为一个基于缓冲区,并能提供异步(non-blocking)IO操作的API被引入。本文对其进行深入的介绍。

    Ja-netfiter-2022.2.0 主要更新对 jdk 17的兼容

    jdk 17需要 新增 配置 如下 jvm参数 --add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED

    java.nio API详解

    在JDK 1.4以前,Java的IO操作集中在java.io这个包中,是基于流的同步(blocking)API。对于大多数应用来说,这样的API使用很方便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来...

    bcprov-ext-jdk15on-1.54.jar,bcprov-jdk15on-1.54.jar

    解决java.lang.RuntimeException: Could not generate DH keypair。这个的Jar包

    jdk_8.0.1310.11_64.zip

    jdk_8.0.1310.11_64——(JDK8版本,对应Java1.8,64位)

    jdk_8.0.1310.11_64.exe -64位

    jdk_8.0.1310.11_64.exe -64位 可用! !!!!!!!

    JDK 开发工具包 17.0.7

    新增和增强的 API:JDK 17.0.7 包含了许多新的和增强的 Java API,例如 Java 媒体框架、Java 加密框架、Java 容器平台等,为开发人员提供了更多的工具和功能。 更好的安全性:JDK 17.0.7 包括许多安全改进,例如增强...

    bcprov-ext-jdk15on-164.jar

    bcprov-ext-jdk15on-164.jar:支持java5-11。将jar包放置在%java_home%/jre/lib/ext目录。

    bcprov-jdk15on-1.65.jar

    最新版的JAVA加密算法包。 The Bouncy Castle Crypto package is a Java implementation of... This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.

    jdk api 1.8_google.CHM

    Java1.8中文API(google翻译版) 文件名:jdk api 1.8_google.CHM 文件大小:40.8M

    jdk1.6 for linux & windows.rar

    压缩包内包含jdk1.6.0_37 for linux 和 jdk-6u45-windows-x64 两个版本。

    jdk7.win32.x86_64_1.7.0.u45

    JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。

    jdk 1.8 linux 32&64 .zip

    jdk 8 用于linux 的tar.gz 32 位与 64位 ,不需要登录再从官网下载。

Global site tag (gtag.js) - Google Analytics