Java I/O (第二版) I/O基础 I/O概述

第一部分

第一章

介绍I/O

输入和输出,的简写I/O,它是任何操作系统和程序设计语言所必须的基础功能。只有空想家才会喜欢没有输入输出的程序。同时,IO的话题似乎对程序员没有什么吸引力。

其实不然,我们应该有很多有趣的东西需要学习在IO中。Java包含了一个丰富的IO classes在核心的api中,大部分在java.io和java.nio中。这些包支持几种不同的IO。如上面提到的字节流,和读写器,writer和reader字符流。还有就是新IO提供了非阻塞的IO,主要用于服务器编程。这些都是很有用的,我们只有掌握了它们的特性,才能在程序的适当时候使用它。

Java的IO很是抽象层面的,它允许你读取或写入外部目标(文件、线程等等),不管你的目标是什么。因为接口,因为多态,你能使用相同的方法读取文件、控制台、网络连接。你使用相同的方法写文件、字节数组、或者是连接。

使用相同的函数操作不同的目标数据是很方便的。除此之外,这允许你去定义系统自动压缩、加密并过滤使一种数据转换成另一种。一旦你有了这些工具,编程发送加密数据或者写入压缩文件就几乎不需要这方面的具体操作,流对象已经封装了这些操作。加密和压缩可以通过几行配置实现。

在这本书中,我们讲学习Java IO的各个部分。包括:所有的流、通道和缓冲(用来提高性能、吞吐量非阻塞操作在服务器端)。我们也将会研究Unicode。我们还会研究IO的格式化在Java中的用法。最后,我们将会了解一下底层的IO通过一些设备(如:串行端口、并行端口、USB、蓝牙、和其他硬件等等)。

最后我想说,Java I/O很有意思!I/O就是应用程序与外界的交流,而Java已经很方便了这种交流。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Input/output (I/O) is not a sexy subject, but it’s an important part of non-trivial applications. This book introduces you to most of Java’s I/O capabilities as of Java 8 update 51. Chapter 1 presents a broad overview of I/O in terms of Java’s classic I/O, New I/O (NIO), and NIO.2 categories. You learn what each category offers in terms of its capabilities, and you also learn about concepts such as paths and Direct Memory Access. Chapters 2 through 5 cover classic I/O APIs. You learn about the File and RandomAccessFile classes along with streams (including object serialization and externalization) and writers/readers. Chapters 6 through 11 focus on NIO. You explore buffers, channels, selectors, regular expressions, charsets, and formatters. (Formatters were not introduced with the other NIO types in Java 1.4 because they depend on the variable arguments capability that was introduced in Java 5.) NIO is missing several features, which were subsequently provided by NIO.2. Chapters 12 through 14 cover NIO.2’s improved file system interface, asynchronous I/O, and the completion of socket channel functionality. Each chapter ends with assorted exercises that are designed to help you master its content. Along with long answers and true/false questions, you are often confronted with programming exercises. Appendix A provides the answers and solutions. Appendix B provides a tutorial on sockets and network interfaces. Although not directly related to classic I/O, NIO, and NIO.2, they leverage I/O capabilities and are mentioned elsewhere in this book.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值