Skip navigation links
Java™ Platform
Standard Ed. 8

Package java.nio

定义缓冲区,它们是数据容器,并提供其他NIO包的概述。

See: 描述

Package java.nio Description

定义缓冲区,它们是数据容器,并提供其他NIO包的概述。

NIO API的中心抽象是:

java.nio包定义了在整个NIO API中使用的缓冲区类。 charset API在java.nio.charset包中定义,通道和选择器API在java.nio.channels包中定义。 这些子包中的每一个都有自己的服务提供商(SPI)子包,其内容可以用于扩展平台的默认实现或构建替代实现。

Buffers

描述

Buffer Position, limit, and capacity;
clear, flip, rewind, and mark/reset
  ByteBuffer Get/put, compact, views; allocate, wrap
    MappedByteBuffer   A byte buffer mapped to a file
  CharBuffer Get/put, compact; allocate, wrap
  DoubleBuffer     ' '
  FloatBuffer     ' '
  IntBuffer     ' '
  LongBuffer     ' '
  ShortBuffer     ' '
ByteOrder Typesafe enumeration for byte orders

缓冲区是用于固定数量的特定原始类型的数据的容器。 除了内容之外,缓冲区还有一个位置 ,它是要读取或写入的下一个元素的索引,以及一个限制 ,它是不应被读取或写入的第一个元素的索引。 基础Buffer类定义了这些属性以及清除翻转倒带的方法 ,用于标记当前位置,以及将位置重置为上一个标记。

每个非布尔基元类型都有一个缓冲区类。 每个类定义一组用于将数据移出和移入缓冲区的getput方法,用于压缩复制分割缓冲区的方法,以及用于分配新缓冲区以及将现有阵列包装到一个缓冲区中的静态方法缓冲。

字节缓冲区的区别在于它们可以用作I / O操作的源和目标。 它们还支持其他缓冲区类中没有的几个功能:

除非另有说明,否则将null参数传递给此程序包中任何类或接口中的构造函数或方法将导致抛出NullPointerException

从以下版本开始:
1.4
Skip navigation links
Java™ Platform
Standard Ed. 8

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.

本帮助文档是使用 《谷歌翻译》翻译,请与英文版配合使用 by--QQ:654638585