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
分享到:
相关推荐
**Java Development Kit (JDK) 1.7 Update 80 for Windows 64-bit** JDK 1.7, also known as Java SE (Standard Edition) 7, is a crucial software development kit for building and running Java applications ...
3. **JSR 203 (NIO.2)**:Java 7添加了新的I/O API,即JSR 203,也称为NIO.2。这个扩展提供了异步文件操作、文件属性查询、文件路径操作以及更好的文件系统抽象。这些改进使得Java在处理I/O操作时更加高效和灵活。 ...
了解`module-info.java`文件的处理方式,可以预见JDK 9及后续版本的模块化系统。 8. **反射与注解** 反射和注解是Java的重要特性,允许运行时动态地获取类信息和元数据。`java.lang.reflect`包提供了反射API,`...
JDK1.8 介绍 JDK原始阅读,注释 文件开头的备注,是关于此类的重点或关键问题 ///开头或/\*/开头的注释,是阅读过程中添加的 内容 java.util.concurrent 质量管理体系 收藏 java.util.stream ...java.nio
Java JDK源码是Java开发工具包的原始代码,对于深入理解Java语言的工作原理以及进行高级编程和优化至关重要。源码包含了Java平台的核心类库,如`java.lang`, `java.util`, `java.io`, `java.nio`等,这些库提供了...
在这个名为"java1.7源码-jdk7-sourcecode-read"的资源中,包含了Java 7的源代码,对于学习和理解Java语言的内部工作原理非常有帮助。下面将详细介绍Java 7的一些关键知识点: 1. **Try-with-resources语句**:Java ...
Java源代码是编程者深入理解Java语言和JDK工作原理的重要资源。这个压缩包包含了从Java 6到Java 10的源代码,包括jdk1.6,jdk1.7,jdk1.8以及jdk10的src-jdk1.8源代码。这些版本的源码代表了Java在不同时间点的发展...
8. **编译与运行**:源代码文件`.java`需要通过JDK(Java Development Kit)中的`javac`命令编译成`.class`字节码文件,然后通过`java`命令运行。 9. **版本控制**:虽然文件列表中没有提及,但开发过程中可能使用...
此外,JDK源码还包括了`java.nio`包,它是新式的I/O模型,提供了非阻塞I/O和通道的概念,对于高性能服务器端应用非常有用。还有`java.net`包,包含了网络通信相关的类,如`Socket`, `ServerSocket`等,对于网络编程...
本项目解释的Java版本为jdk-8u271-windows-x64 。使用JUnit5库进行测试和验证工作。 项目结构 src文件夹:包含对Java源码的解释文档和其他相关知识的文档,和Java源码目录保持一致,只是在后面加上“ _”以区别 测试...
"sourcecode-java:Java SE源码库"标题表明这是一个包含Java SE源代码的资源,对于学习和深入理解Java语言的内部机制非常有价值。 描述中提到的"Java SE原始库,方便学习和研究",意味着这个压缩包很可能包含了Java ...
在Java7SourceCode项目中,你可以找到这些特性的具体实现,例如`java.util.concurrent`包下的ForkJoinPool和RecursiveTask类,`java.nio.file`包中的Path和Files类,以及`java.lang.invoke`包下的相关类。...
java api和源码 javase_review review java SE deeping with source code,and implements ...JDK ...source code ... java.lang java.util java.io ... java.lang.reflect ... java.nio.* java.util.concurrent.* 第
### Java JDK 1.7 知识点详解 #### 一、Java JDK 1.7 概述 Java Development Kit (JDK) 是一个由Oracle公司提供的Java开发工具包,包含了编译、运行和调试Java应用程序所需的所有工具。Java JDK 1.7,即Java ...
"JDK-sourcecode-analysis: JDK原始阅读笔记"项目,旨在帮助开发者深入理解JDK的核心机制,通过源码分析,我们可以揭示Java语言背后的秘密,增强我们的编程能力。 首先,让我们探讨一下"系统开源"这个标签的含义。...
本文将深入剖析JDK8的源代码,涵盖JVM、并发、IO/NIO、反射、网络、注解、集合、JDBC以及Java8的新特性,旨在帮助读者更全面地理解Java平台的核心技术。 一、JVM(Java虚拟机) JVM是Java程序运行的基础,它负责...
To learn how to use the API, since documentation currently lacks, please refer to the Sample Usage section below as well as the sample programs, including two for Android (FacePreview.java and Record...
collection Java 源码 概述 主要分析 JDK8 源码。 基础 java-io java-nio java-reflect java-collection java-annotation java-net java-jdbc java-concurrent java-jvm java8
3. **I/O流**:`java.io`包提供了丰富的流处理类,通过源码我们可以学习如何进行数据的读写,了解缓冲流、字符流与字节流的区别,以及NIO(非阻塞I/O)的实现。 4. **集合框架**:Java集合框架是数据结构和算法的...
源码附件"Apress - Beginning Java SE 6 Platform (SourceCode).zip"提供了书中示例代码,读者可以动手实践,加深理解。通过这些代码,你可以学习如何应用上述知识点,解决实际问题,提高编程技能。 总的来说,...